KiCad PCB EDA Suite
Loading...
Searching...
No Matches
command_pcb_export_gerber.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) 2022 Mark Roszko <[email protected]>
5 * Copyright The 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 <wx/crt.h>
25
26#include <macros.h>
27#include <string_utils.h>
28
29
31 PCB_EXPORT_BASE_COMMAND( aName, IO_TYPE::FILE, aOutputType )
32{
35
38
39 m_argParser.add_description( UTF8STDSTR( _( "Plot given layers to a single Gerber file" ) ) );
40
41 m_argParser.add_argument( "--erd", ARG_EXCLUDE_REFDES )
42 .help( UTF8STDSTR( _( "Exclude the reference designator text" ) ) )
43 .flag();
44
45 m_argParser.add_argument( "--ev", ARG_EXCLUDE_VALUE )
46 .help( UTF8STDSTR( _( "Exclude the value text" ) ) )
47 .flag();
48
49 m_argParser.add_argument( "--ibt", ARG_INCLUDE_BORDER_TITLE )
50 .help( UTF8STDSTR( _( "Include the border and title block" ) ) )
51 .flag();
52
53 m_argParser.add_argument( "--sp", ARG_SKETCH_PADS_ON_FAB_LAYERS )
55 .flag();
56
57 m_argParser.add_argument( "--hdnp", ARG_HIDE_DNP_FPS_ON_FAB_LAYERS )
59 .flag();
60
61 m_argParser.add_argument( "--sdnp", ARG_SKETCH_DNP_FPS_ON_FAB_LAYERS )
63 .flag();
64
65 m_argParser.add_argument( "--cdnp", ARG_CROSSOUT_DNP_FPS_ON_FAB_LAYERS )
67 .flag();
68
69 m_argParser.add_argument( ARG_NO_X2 )
70 .help( UTF8STDSTR( _( "Do not use the extended X2 format" ) ) )
71 .flag();
72
73 m_argParser.add_argument( ARG_NO_NETLIST )
74 .help( UTF8STDSTR( _( "Do not generate netlist attributes" ) ) )
75 .flag();
76
78 .help( UTF8STDSTR( _( "Subtract soldermask from silkscreen" ) ) )
79 .flag();
80
82 .help( UTF8STDSTR( _( "Disable aperture macros" ) ) )
83 .flag();
84
86 .help( UTF8STDSTR( _( "Use drill/place file origin" ) ) )
87 .flag();
88
89 m_argParser.add_argument( ARG_PRECISION )
90 .help( UTF8STDSTR( _( "Precision of Gerber coordinates, valid options: 5 or 6" ) ) )
91 .scan<'i', int>()
92 .default_value( 6 )
93 .metavar( "PRECISION" );
94
96 .help( UTF8STDSTR( _( "Use KiCad Gerber file extension" ) ) )
97 .flag();
98
99 m_argParser.add_argument( ARG_CHECK_ZONES )
100 .help( UTF8STDSTR( _( ARG_CHECK_ZONES_DESC ) ) )
101 .flag();
102}
103
104
106{
107 aJob->m_filename = m_argInput;
111 if( aJob->m_sketchPadsOnFabLayers )
112 aJob->m_plotPadNumbers = true;
117
119 aJob->m_plotRefDes = !m_argParser.get<bool>( ARG_EXCLUDE_REFDES );
124 aJob->m_useX2Format = !m_argParser.get<bool>( ARG_NO_X2 );
127 aJob->m_precision = m_argParser.get<int>( ARG_PRECISION );
129
130 aJob->m_argLayers = From_UTF8( m_argParser.get<std::string>( ARG_LAYERS ).c_str() );
131 aJob->m_argCommonLayers = From_UTF8( m_argParser.get<std::string>( ARG_COMMON_LAYERS ).c_str() );
132
133 if( !wxFile::Exists( aJob->m_filename ) )
134 {
135 wxFprintf( stderr, _( "Board file does not exist or is not accessible\n" ) );
137 }
138
139 if( aJob->m_precision != 5 && aJob->m_precision != 6 )
140 {
141 wxFprintf( stderr, _( "Gerber coordinate precision should be either 5 or 6\n" ) );
143 }
144
145 return EXIT_CODES::OK;
146}
std::map< wxString, wxString > m_argDefineVars
Value of the drawing sheet arg if configured.
Definition command.h:158
argparse::ArgumentParser m_argParser
Definition command.h:113
void addDefineArg()
Set up the drawing sheet arg used by many of the export commands.
Definition command.cpp:212
wxString m_argDrawingSheet
Value of the drawing sheet arg if configured.
Definition command.h:153
wxString m_argOutput
Value of the output arg if configured.
Definition command.h:148
wxString m_argInput
Value of the common input arg if configured.
Definition command.h:143
void addDrawingSheetArg()
Set up the drawing sheet arg used by many of the export commands.
Definition command.cpp:200
int populateJob(JOB_EXPORT_PCB_GERBER *aJob)
PCB_EXPORT_GERBER_COMMAND(const std::string &aName, IO_TYPE aOutputType)
std::optional< wxString > m_argLayers
std::optional< wxString > m_argCommonLayers
void SetConfiguredOutputPath(const wxString &aPath)
Sets the configured output path for the job, this path is always saved to file.
Definition job.cpp:157
void SetVarOverrides(const std::map< wxString, wxString > &aVarOverrides)
Definition job.h:199
#define UTF8STDSTR(s)
Definition command.h:27
#define ARG_SKETCH_PADS_ON_FAB_LAYERS_DESC
#define ARG_INCLUDE_BORDER_TITLE
#define ARG_CROSSOUT_DNP_FPS_ON_FAB_LAYERS_DESC
#define ARG_CHECK_ZONES_DESC
#define ARG_SKETCH_PADS_ON_FAB_LAYERS
#define ARG_COMMON_LAYERS
#define ARG_SKETCH_DNP_FPS_ON_FAB_LAYERS_DESC
#define ARG_EXCLUDE_REFDES
#define ARG_CHECK_ZONES
#define ARG_EXCLUDE_VALUE
#define ARG_CROSSOUT_DNP_FPS_ON_FAB_LAYERS
#define ARG_HIDE_DNP_FPS_ON_FAB_LAYERS
#define ARG_SUBTRACT_SOLDERMASK
#define ARG_LAYERS
#define ARG_HIDE_DNP_FPS_ON_FAB_LAYERS_DESC
#define ARG_SKETCH_DNP_FPS_ON_FAB_LAYERS
#define ARG_PRECISION
#define ARG_NO_X2
#define ARG_NO_NETLIST
#define ARG_DISABLE_APERTURE_MACROS
#define ARG_USE_DRILL_FILE_ORIGIN
#define ARG_NO_PROTEL_EXTENSION
#define _(s)
This file contains miscellaneous commonly used macros and functions.
static const int ERR_ARGS
Definition exit_codes.h:31
static const int OK
Definition exit_codes.h:30
static const int ERR_INVALID_INPUT_FILE
Definition exit_codes.h:33
wxString From_UTF8(const char *cstring)
PCB_EXPORT_BASE_COMMAND(const std::string &aName, IO_TYPE aInputType=IO_TYPE::FILE, IO_TYPE aOutputType=IO_TYPE::FILE)