32#define ARG_DRILL_ORIGIN "--drill-origin"
33#define ARG_GRID_ORIGIN "--grid-origin"
34#define ARG_NO_UNSPECIFIED "--no-unspecified"
35#define ARG_NO_DNP "--no-dnp"
36#define ARG_SUBST_MODELS "--subst-models"
37#define ARG_FORCE "--force"
38#define ARG_MIN_DISTANCE "--min-distance"
39#define ARG_USER_ORIGIN "--user-origin"
40#define ARG_BOARD_ONLY "--board-only"
41#define ARG_CUT_VIAS_IN_BODY "--cut-vias-in-body"
42#define ARG_NO_BOARD_BODY "--no-board-body"
43#define ARG_NO_COMPONENTS "--no-components"
44#define ARG_INCLUDE_TRACKS "--include-tracks"
45#define ARG_INCLUDE_PADS "--include-pads"
46#define ARG_INCLUDE_ZONES "--include-zones"
47#define ARG_INCLUDE_INNER_COPPER "--include-inner-copper"
48#define ARG_INCLUDE_SILKSCREEN "--include-silkscreen"
49#define ARG_INCLUDE_SOLDERMASK "--include-soldermask"
50#define ARG_FUSE_SHAPES "--fuse-shapes"
51#define ARG_FILL_ALL_VIAS "--fill-all-vias"
52#define ARG_NO_OPTIMIZE_STEP "--no-optimize-step"
53#define ARG_NET_FILTER "--net-filter"
54#define ARG_FORMAT "--format"
55#define ARG_VRML_UNITS "--units"
56#define ARG_VRML_MODELS_DIR "--models-dir"
57#define ARG_VRML_MODELS_RELATIVE "--models-relative"
58#define ARG_COMPONENT_FILTER "--component-filter"
60#define REGEX_QUANTITY "([\\s]*[+-]?[\\d]*[.]?[\\d]*)"
61#define REGEX_DELIMITER "(?:[\\s]*x)"
62#define REGEX_UNIT "([m]{2}|(?:in))"
65 const std::string& aDescription,
77 .default_value( std::string(
"step" ) )
79 _(
"Output file format, options: step, brep, xao, glb (binary glTF), ply, stl" ) ) );
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" ) ) )
101 .help(
UTF8STDSTR(
_(
"Use Grid Origin for output origin" ) ) )
105 .help(
UTF8STDSTR(
_(
"Use Drill Origin for output origin" ) ) )
109 .help(
UTF8STDSTR(
_(
"Substitute STEP or IGS models with the same name in place "
110 "of VRML models" ) ) )
114 .help(
UTF8STDSTR(
_(
"Only generate a board with no components" ) ) )
118 .help(
UTF8STDSTR(
_(
"Cut via holes in board body even if conductor layers are "
119 "not exported." ) ) )
127 .help(
UTF8STDSTR(
_(
"Exclude 3D models for components" ) ) )
131 .help(
UTF8STDSTR(
_(
"Only include component 3D models matching this list of "
132 "reference designators (comma-separated, wildcards supported)"
134 .default_value( std::string() );
137 .help(
UTF8STDSTR(
_(
"Export tracks and vias" ) ) )
149 .help(
UTF8STDSTR(
_(
"Export elements on inner copper layers" ) ) )
153 .help(
UTF8STDSTR(
_(
"Export silkscreen graphics as a set of flat faces" ) ) )
157 .help(
UTF8STDSTR(
_(
"Export soldermask layers as a set of flat faces" ) ) )
161 .help(
UTF8STDSTR(
_(
"Fuse overlapping geometry together" ) ) )
165 .help(
UTF8STDSTR(
_(
"Don't cut via holes in conductor layers." ) ) )
169 .default_value( std::string(
"0.01mm" ) )
171 _(
"Minimum distance between points to treat them as separate ones" ) ) )
172 .metavar(
"MIN_DIST" );
175 .default_value( std::string() )
177 "Only include copper items belonging to nets matching this wildcard" ) ) );
183 .help(
UTF8STDSTR(
_(
"Do not optimize STEP file (enables writing parametric "
189 .default_value( std::string() )
190 .help(
UTF8STDSTR(
_(
"User-specified output origin ex. 1x1in, 1x1inch, 25.4x25.4mm "
191 "(default unit mm)" ) ) );
196 .default_value( std::string(
"in" ) )
198 _(
"Output units; valid options: mm, m, in, tenths" ) ) );
201 .default_value( std::string(
"" ) )
203 _(
"Name of folder to create and store 3d models in, if not specified or "
204 "empty, the models will be embedded in main exported VRML file" ) ) );
207 .help(
UTF8STDSTR(
_(
"Used with --models-dir to output relative paths in the "
208 "resulting file" ) ) )
250 step->SetConfiguredOutputPath( m_argOutput );
252 step->m_filename = m_argInput;
253 step->m_format = m_format;
254 step->SetVarOverrides( m_argDefineVars );
260 if( format == wxS(
"step" ) )
262 else if( format == wxS(
"brep" ) )
264 else if( format == wxS(
"xao" ) )
266 else if( format == wxS(
"glb" ) )
268 else if( format == wxS(
"ply" ) )
270 else if( format == wxS(
"stl" ) )
274 wxFprintf( stderr,
_(
"Invalid format specified\n" ) );
283 if( units == wxS(
"in" ) )
285 else if( units == wxS(
"mm" ) )
287 else if( units == wxS(
"m" ) )
289 else if( units == wxS(
"tenths" ) )
293 wxFprintf( stderr,
_(
"Invalid units specified\n" ) );
306 if( !userOrigin.IsEmpty() )
309 std::regex_constants::icase );
311 std::string str( userOrigin.ToUTF8() );
312 std::regex_search( str, sm, re_pattern );
313 step->m_3dparams.m_Origin.x = atof( sm.str( 1 ).c_str() );
314 step->m_3dparams.m_Origin.y = atof( sm.str( 2 ).c_str() );
318 step->m_3dparams.m_Origin.x =
pcbIUScale.
mmToIU( step->m_3dparams.m_Origin.x );
319 step->m_3dparams.m_Origin.y =
pcbIUScale.
mmToIU( step->m_3dparams.m_Origin.y );
321 std::string tunit( sm[3] );
323 if( tunit.size() > 0 )
325 if( ( !sm.str( 1 ).compare(
" " ) || !sm.str( 2 ).compare(
" " ) )
326 || ( sm.size() != 4 ) )
328 std::cout << m_argParser;
333 if( !tunit.compare(
"in" ) || !tunit.compare(
"inch" ) )
335 step->m_3dparams.m_Origin *= 25.4;
337 else if( tunit.compare(
"mm" ) )
339 std::cout << m_argParser;
344 step->m_hasUserOrigin =
true;
350 wxString minDistance =
353 if( !minDistance.IsEmpty() )
357 std::string str( minDistance.ToUTF8() );
358 std::regex_search( str, sm, re_pattern );
359 step->m_3dparams.m_BoardOutlinesChainingEpsilon = atof( sm.str( 1 ).c_str() );
361 std::string tunit( sm[2] );
363 if( tunit.size() > 0 )
365 if( !tunit.compare(
"in" ) || !tunit.compare(
"inch" ) )
367 step->m_3dparams.m_BoardOutlinesChainingEpsilon *= 25.4;
369 else if( tunit.compare(
"mm" ) )
371 std::cout << m_argParser;
constexpr EDA_IU_SCALE pcbIUScale
argparse::ArgumentParser m_argParser
void addDefineArg()
Set up the drawing sheet arg used by many of the export commands.
void addCommonArgs(bool aInput, bool aOutput, bool aInputIsDir, bool aOutputIsDir)
Set up the most common of args used across cli.
bool m_IncludeUnspecified
wxString m_ComponentFilter
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
int ProcessJob(KIWAY::FACE_T aFace, JOB *aJob, REPORTER *aReporter=nullptr)
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_SILKSCREEN
#define ARG_INCLUDE_TRACKS
#define ARG_INCLUDE_ZONES
#define ARG_INCLUDE_INNER_COPPER
#define ARG_VRML_MODELS_RELATIVE
#define ARG_NO_OPTIMIZE_STEP
#define ARG_CUT_VIAS_IN_BODY
#define ARG_INCLUDE_SOLDERMASK
#define ARG_FILL_ALL_VIAS
#define ARG_NO_BOARD_BODY
#define ARG_NO_COMPONENTS
#define ARG_COMPONENT_FILTER
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