31#define ARG_DRILL_ORIGIN "--drill-origin"
32#define ARG_GRID_ORIGIN "--grid-origin"
33#define ARG_NO_UNSPECIFIED "--no-unspecified"
34#define ARG_NO_DNP "--no-dnp"
35#define ARG_SUBST_MODELS "--subst-models"
36#define ARG_FORCE "--force"
37#define ARG_MIN_DISTANCE "--min-distance"
38#define ARG_USER_ORIGIN "--user-origin"
39#define ARG_BOARD_ONLY "--board-only"
40#define ARG_INCLUDE_TRACKS "--include-tracks"
41#define ARG_INCLUDE_ZONES "--include-zones"
42#define ARG_NO_OPTIMIZE_STEP "--no-optimize-step"
43#define ARG_FORMAT "--format"
44#define ARG_VRML_UNITS "--units"
45#define ARG_VRML_MODELS_DIR "--models-dir"
46#define ARG_VRML_MODELS_RELATIVE "--models-relative"
48#define REGEX_QUANTITY "([\\s]*[+-]?[\\d]*[.]?[\\d]*)"
49#define REGEX_DELIMITER "(?:[\\s]*x)"
50#define REGEX_UNIT "([m]{2}|(?:in))"
53 const std::string& aDescription,
65 .default_value( std::string(
"step" ) )
66 .help(
UTF8STDSTR(
_(
"Output file format, options: step, glb (binary glTF)" ) ) );
71 .implicit_value(
true )
72 .default_value(
false );
77 .help(
UTF8STDSTR(
_(
"Use Grid Origin for output origin" ) ) )
78 .implicit_value(
true )
79 .default_value(
false );
82 .help(
UTF8STDSTR(
_(
"Use Drill Origin for output origin" ) ) )
83 .implicit_value(
true )
84 .default_value(
false );
88 "Exclude 3D models for components with 'Unspecified' footprint type" ) ) )
89 .implicit_value(
true )
90 .default_value(
false );
94 _(
"Exclude 3D models for components with 'Do not populate' attribute" ) ) )
95 .implicit_value(
true )
96 .default_value(
false );
99 .help(
UTF8STDSTR(
_(
"Substitute STEP or IGS models with the same name in place "
100 "of VRML models" ) ) )
101 .implicit_value(
true )
102 .default_value(
false );
105 .help(
UTF8STDSTR(
_(
"Only generate a board with no components" ) ) )
106 .implicit_value(
true )
107 .default_value(
false );
110 .help(
UTF8STDSTR(
_(
"Export tracks (time consuming)" ) ) )
111 .implicit_value(
true )
112 .default_value(
false );
115 .help(
UTF8STDSTR(
_(
"Export zones (time consuming)" ) ) )
116 .implicit_value(
true )
117 .default_value(
false );
120 .default_value( std::string(
"0.01mm" ) )
122 _(
"Minimum distance between points to treat them as separate ones" ) ) )
123 .metavar(
"MIN_DIST" );
129 .help(
UTF8STDSTR(
_(
"Do not optimize STEP file (enables writing parametric curves)" ) ) )
130 .implicit_value(
true )
131 .default_value(
false );
135 .default_value( std::string() )
136 .help(
UTF8STDSTR(
_(
"User-specified output origin ex. 1x1in, 1x1inch, 25.4x25.4mm (default unit mm)" ) ) );
141 .default_value( std::string(
"in" ) )
143 _(
"Output units; ascii or csv format only; valid options: mm, m, in, tenths" ) ) );
146 .default_value( std::string(
"" ) )
148 _(
"Name of folder to create and store 3d models in, if not specified or "
149 "empty, the models will be embedded in main exported vrml file" ) ) );
152 .help(
UTF8STDSTR(
_(
"Used with --models-dir to output relative paths in the resulting file" ) ) )
153 .implicit_value(
true )
154 .default_value(
false );
167 step->m_includeDNP = !m_argParser.get<
bool>(
ARG_NO_DNP );
179 step->m_overwrite = m_argParser.get<
bool>(
ARG_FORCE );
180 step->m_filename = m_argInput;
181 step->m_outputFile = m_argOutput;
182 step->m_format = m_format;
183 step->SetVarOverrides( m_argDefineVars );
189 if( format == wxS(
"step" ) )
191 else if( format == wxS(
"glb" ) )
195 wxFprintf( stderr,
_(
"Invalid format specified\n" ) );
204 if( units == wxS(
"in" ) )
206 else if( units == wxS(
"mm" ) )
208 else if( units == wxS(
"m" ) )
210 else if( units == wxS(
"tenths" ) )
214 wxFprintf( stderr,
_(
"Invalid units specified\n" ) );
227 if( !userOrigin.IsEmpty() )
230 std::regex_constants::icase );
232 std::string str( userOrigin.ToUTF8() );
233 std::regex_search( str, sm, re_pattern );
234 step->m_xOrigin = atof( sm.str( 1 ).c_str() );
235 step->m_yOrigin = atof( sm.str( 2 ).c_str() );
242 std::string tunit( sm[3] );
244 if( tunit.size() > 0 )
246 if( ( !sm.str( 1 ).compare(
" " ) || !sm.str( 2 ).compare(
" " ) )
247 || ( sm.size() != 4 ) )
249 std::cout << m_argParser;
254 if( !tunit.compare(
"in" ) || !tunit.compare(
"inch" ) )
256 step->m_xOrigin *= 25.4;
257 step->m_yOrigin *= 25.4;
259 else if( tunit.compare(
"mm" ) )
261 std::cout << m_argParser;
266 step->m_hasUserOrigin =
true;
271 wxString minDistance =
274 if( !minDistance.IsEmpty() )
278 std::string str( minDistance.ToUTF8() );
279 std::regex_search( str, sm, re_pattern );
280 step->m_BoardOutlinesChainingEpsilon = atof( sm.str( 1 ).c_str() );
282 std::string tunit( sm[2] );
284 if( tunit.size() > 0 )
286 if( !tunit.compare(
"in" ) || !tunit.compare(
"inch" ) )
288 step->m_BoardOutlinesChainingEpsilon *= 25.4;
290 else if( tunit.compare(
"mm" ) )
292 std::cout << m_argParser;
constexpr EDA_IU_SCALE pcbIUScale
argparse::ArgumentParser m_argParser
void addDefineArg()
Sets up the drawing sheet arg used by many of the export commands.
void addCommonArgs(bool aInput, bool aOutput, bool aInputIsDir, bool aOutputIsDir)
Sets up the most common of args used across cli.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
int ProcessJob(KIWAY::FACE_T aFace, JOB *job)
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
#define ARG_VRML_MODELS_DIR
#define ARG_NO_UNSPECIFIED
#define ARG_INCLUDE_TRACKS
#define ARG_INCLUDE_ZONES
#define ARG_VRML_MODELS_RELATIVE
#define ARG_NO_OPTIMIZE_STEP
This file contains miscellaneous commonly used macros and functions.
static const int ERR_ARGS
std::vector< FAB_LAYER_COLOR > dummy
wxString From_UTF8(const char *cstring)
PCB_EXPORT_3D_COMMAND(const std::string &aName, const std::string &aDescription, JOB_EXPORT_PCB_3D::FORMAT aFormat=JOB_EXPORT_PCB_3D::FORMAT::UNKNOWN)
int doPerform(KIWAY &aKiway) override
The internal handler that should be overloaded to implement command specific processing and work.
JOB_EXPORT_PCB_3D::FORMAT m_format
constexpr int mmToIU(double mm) const