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_NO_BOARD_BODY "--no-board-body"
42#define ARG_NO_COMPONENTS "--no-components"
43#define ARG_INCLUDE_TRACKS "--include-tracks"
44#define ARG_INCLUDE_PADS "--include-pads"
45#define ARG_INCLUDE_ZONES "--include-zones"
46#define ARG_INCLUDE_INNER_COPPER "--include-inner-copper"
47#define ARG_INCLUDE_SILKSCREEN "--include-silkscreen"
48#define ARG_INCLUDE_SOLDERMASK "--include-soldermask"
49#define ARG_FUSE_SHAPES "--fuse-shapes"
50#define ARG_NO_OPTIMIZE_STEP "--no-optimize-step"
51#define ARG_NET_FILTER "--net-filter"
52#define ARG_FORMAT "--format"
53#define ARG_VRML_UNITS "--units"
54#define ARG_VRML_MODELS_DIR "--models-dir"
55#define ARG_VRML_MODELS_RELATIVE "--models-relative"
56#define ARG_COMPONENT_FILTER "--component-filter"
58#define REGEX_QUANTITY "([\\s]*[+-]?[\\d]*[.]?[\\d]*)"
59#define REGEX_DELIMITER "(?:[\\s]*x)"
60#define REGEX_UNIT "([m]{2}|(?:in))"
63 const std::string& aDescription,
75 .default_value( std::string(
"step" ) )
77 _(
"Output file format, options: step, brep, xao, glb (binary glTF), ply, stl" ) ) );
86 _(
"Exclude 3D models for components with 'Unspecified' footprint type" ) ) )
87 .implicit_value(
true )
88 .default_value(
false );
92 _(
"Exclude 3D models for components with 'Do not populate' attribute" ) ) )
99 .help(
UTF8STDSTR(
_(
"Use Grid Origin for output origin" ) ) )
103 .help(
UTF8STDSTR(
_(
"Use Drill Origin for output origin" ) ) )
107 .help(
UTF8STDSTR(
_(
"Substitute STEP or IGS models with the same name in place "
108 "of VRML models" ) ) )
112 .help(
UTF8STDSTR(
_(
"Only generate a board with no components" ) ) )
120 .help(
UTF8STDSTR(
_(
"Exclude 3D models for components" ) ) )
124 .help(
UTF8STDSTR(
_(
"Only include component 3D models matching this list of "
125 "reference designators (comma-separated, wildcards supported)"
127 .default_value( std::string() );
130 .help(
UTF8STDSTR(
_(
"Export tracks and vias" ) ) )
142 .help(
UTF8STDSTR(
_(
"Export elements on inner copper layers" ) ) )
146 .help(
UTF8STDSTR(
_(
"Export silkscreen graphics as a set of flat faces" ) ) )
150 .help(
UTF8STDSTR(
_(
"Export soldermask layers as a set of flat faces" ) ) )
154 .help(
UTF8STDSTR(
_(
"Fuse overlapping geometry together" ) ) )
158 .default_value( std::string(
"0.01mm" ) )
160 _(
"Minimum distance between points to treat them as separate ones" ) ) )
161 .metavar(
"MIN_DIST" );
164 .default_value( std::string() )
166 "Only include copper items belonging to nets matching this wildcard" ) ) );
172 .help(
UTF8STDSTR(
_(
"Do not optimize STEP file (enables writing parametric "
178 .default_value( std::string() )
179 .help(
UTF8STDSTR(
_(
"User-specified output origin ex. 1x1in, 1x1inch, 25.4x25.4mm "
180 "(default unit mm)" ) ) );
185 .default_value( std::string(
"in" ) )
187 _(
"Output units; valid options: mm, m, in, tenths" ) ) );
190 .default_value( std::string(
"" ) )
192 _(
"Name of folder to create and store 3d models in, if not specified or "
193 "empty, the models will be embedded in main exported VRML file" ) ) );
196 .help(
UTF8STDSTR(
_(
"Used with --models-dir to output relative paths in the "
197 "resulting file" ) ) )
237 step->SetOutputPath( m_argOutput );
239 step->m_filename = m_argInput;
240 step->m_format = m_format;
241 step->SetVarOverrides( m_argDefineVars );
247 if( format == wxS(
"step" ) )
249 else if( format == wxS(
"brep" ) )
251 else if( format == wxS(
"xao" ) )
253 else if( format == wxS(
"glb" ) )
255 else if( format == wxS(
"ply" ) )
257 else if( format == wxS(
"stl" ) )
261 wxFprintf( stderr,
_(
"Invalid format specified\n" ) );
270 if( units == wxS(
"in" ) )
272 else if( units == wxS(
"mm" ) )
274 else if( units == wxS(
"m" ) )
276 else if( units == wxS(
"tenths" ) )
280 wxFprintf( stderr,
_(
"Invalid units specified\n" ) );
293 if( !userOrigin.IsEmpty() )
296 std::regex_constants::icase );
298 std::string str( userOrigin.ToUTF8() );
299 std::regex_search( str, sm, re_pattern );
300 step->m_3dparams.m_Origin.x = atof( sm.str( 1 ).c_str() );
301 step->m_3dparams.m_Origin.y = atof( sm.str( 2 ).c_str() );
305 step->m_3dparams.m_Origin.x =
pcbIUScale.
mmToIU( step->m_3dparams.m_Origin.x );
306 step->m_3dparams.m_Origin.y =
pcbIUScale.
mmToIU( step->m_3dparams.m_Origin.y );
308 std::string tunit( sm[3] );
310 if( tunit.size() > 0 )
312 if( ( !sm.str( 1 ).compare(
" " ) || !sm.str( 2 ).compare(
" " ) )
313 || ( sm.size() != 4 ) )
315 std::cout << m_argParser;
320 if( !tunit.compare(
"in" ) || !tunit.compare(
"inch" ) )
322 step->m_3dparams.m_Origin *= 25.4;
324 else if( tunit.compare(
"mm" ) )
326 std::cout << m_argParser;
331 step->m_hasUserOrigin =
true;
337 wxString minDistance =
340 if( !minDistance.IsEmpty() )
344 std::string str( minDistance.ToUTF8() );
345 std::regex_search( str, sm, re_pattern );
346 step->m_3dparams.m_BoardOutlinesChainingEpsilon = atof( sm.str( 1 ).c_str() );
348 std::string tunit( sm[2] );
350 if( tunit.size() > 0 )
352 if( !tunit.compare(
"in" ) || !tunit.compare(
"inch" ) )
354 step->m_3dparams.m_BoardOutlinesChainingEpsilon *= 25.4;
356 else if( tunit.compare(
"mm" ) )
358 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)
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_INCLUDE_SOLDERMASK
#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