KiCad PCB EDA Suite
Loading...
Searching...
No Matches
command_pcb_export_gencad.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2024 Julie Vairai <[email protected]>
5 * Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
22#include <cli/exit_codes.h>
24#include <kiface_base.h>
25#include <layer_ids.h>
26#include <string_utils.h>
27#include <wx/crt.h>
28
29#include <macros.h>
30#include <wx/tokenzr.h>
31
32#include <locale_io.h>
33
34
36{
37 m_argParser.add_description( UTF8STDSTR( _( "Generate Gencad from a list of layers" ) ) );
38
39 addLayerArg( true );
42
43 m_argParser.add_argument( "-f", ARG_FLIP_BOTTOM_PADS )
44 .default_value( false )
45 .help( UTF8STDSTR( _( "Flip bottom footprint padstacks" ) ) )
46 .flag();
47
48 m_argParser.add_argument( "", ARG_UNIQUE_PINS )
49 .default_value( false )
50 .help( UTF8STDSTR( _( "Generate unique pin names" ) ) )
51 .flag();
52
53 m_argParser.add_argument( "", ARG_UNIQUE_FOOTPRINTS )
54 .default_value( false )
55 .help( UTF8STDSTR( _(
56 "Generate a new shape for each footprint instance (do not reuse shapes)" ) ) )
57 .flag();
58
59 m_argParser.add_argument( "", ARG_USE_DRILL_ORIGIN )
60 .default_value( false )
61 .help( UTF8STDSTR( _( "Use drill/place file origin as origin" ) ) )
62 .flag();
63
64 m_argParser.add_argument( "", ARG_STORE_ORIGIN_COORD )
65 .default_value( false )
66 .help( UTF8STDSTR( _( "Save the origin coordinates in the file" ) ) )
67 .flag();
68}
69
70
72{
73 int baseExit = PCB_EXPORT_BASE_COMMAND::doPerform( aKiway );
74
75 if( baseExit != EXIT_CODES::OK )
76 return baseExit;
77
78 std::unique_ptr<JOB_EXPORT_PCB_GENCAD> gencadJob( new JOB_EXPORT_PCB_GENCAD() );
79
80 gencadJob->m_filename = m_argInput;
81 gencadJob->SetVarOverrides( m_argDefineVars );
82
83 gencadJob->m_flipBottomPads = m_argParser.get<bool>( ARG_FLIP_BOTTOM_PADS );
84 gencadJob->m_useUniquePins = m_argParser.get<bool>( ARG_UNIQUE_PINS );
85 gencadJob->m_useIndividualShapes = m_argParser.get<bool>( ARG_UNIQUE_FOOTPRINTS );
86 gencadJob->m_useDrillOrigin = m_argParser.get<bool>( ARG_USE_DRILL_ORIGIN );
87 gencadJob->m_storeOriginCoords = m_argParser.get<bool>( ARG_STORE_ORIGIN_COORD );
88
89 if( !wxFile::Exists( gencadJob->m_filename ) )
90 {
91 wxFprintf( stderr, _( "Board file does not exist or is not accessible\n" ) );
93 }
94
95 LOCALE_IO dummy; // Switch to "C" locale
96 int exitCode = aKiway.ProcessJob( KIWAY::FACE_PCB, gencadJob.get() );
97
98 return exitCode;
99}
argparse::ArgumentParser m_argParser
Definition: command.h:100
void addDefineArg()
Set up the drawing sheet arg used by many of the export commands.
Definition: command.cpp:169
void addDrawingSheetArg()
Set up the drawing sheet arg used by many of the export commands.
Definition: command.cpp:157
int doPerform(KIWAY &aKiway) override
The internal handler that should be overloaded to implement command specific processing and work.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:284
int ProcessJob(KIWAY::FACE_T aFace, JOB *aJob)
Definition: kiway.cpp:709
@ FACE_PCB
pcbnew DSO
Definition: kiway.h:292
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:49
#define UTF8STDSTR(s)
Definition: command.h:27
#define ARG_UNIQUE_PINS
#define ARG_FLIP_BOTTOM_PADS
#define ARG_UNIQUE_FOOTPRINTS
#define ARG_USE_DRILL_ORIGIN
#define ARG_STORE_ORIGIN_COORD
#define _(s)
This file contains miscellaneous commonly used macros and functions.
static const int OK
Definition: exit_codes.h:30
static const int ERR_INVALID_INPUT_FILE
Definition: exit_codes.h:33
std::vector< FAB_LAYER_COLOR > dummy
int doPerform(KIWAY &aKiway) override
The internal handler that should be overloaded to implement command specific processing and work.