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)" ) ) );
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" ) ) )
100 .help(
UTF8STDSTR(
_(
"Use Grid Origin for output origin" ) ) )
104 .help(
UTF8STDSTR(
_(
"Use Drill Origin for output origin" ) ) )
108 .help(
UTF8STDSTR(
_(
"Substitute STEP or IGS models with the same name in place "
109 "of VRML models" ) ) )
113 .help(
UTF8STDSTR(
_(
"Only generate a board with no components" ) ) )
121 .help(
UTF8STDSTR(
_(
"Exclude 3D models for components" ) ) )
125 .help(
UTF8STDSTR(
_(
"Only include component 3D models matching this list of "
126 "reference designators (comma-separated, wildcards supported)"
128 .default_value( std::string() );
131 .help(
UTF8STDSTR(
_(
"Export tracks and vias" ) ) )
143 .help(
UTF8STDSTR(
_(
"Export elements on inner copper layers" ) ) )
147 .help(
UTF8STDSTR(
_(
"Export silkscreen graphics as a set of flat faces" ) ) )
151 .help(
UTF8STDSTR(
_(
"Export soldermask layers as a set of flat faces" ) ) )
155 .help(
UTF8STDSTR(
_(
"Fuse overlapping geometry together" ) ) )
159 .default_value( std::string(
"0.01mm" ) )
161 _(
"Minimum distance between points to treat them as separate ones" ) ) )
162 .metavar(
"MIN_DIST" );
165 .default_value( std::string() )
167 "Only include copper items belonging to nets matching this wildcard" ) ) );
173 .help(
UTF8STDSTR(
_(
"Do not optimize STEP file (enables writing parametric "
179 .default_value( std::string() )
180 .help(
UTF8STDSTR(
_(
"User-specified output origin ex. 1x1in, 1x1inch, 25.4x25.4mm "
181 "(default unit mm)" ) ) );
186 .default_value( std::string(
"in" ) )
188 _(
"Output units; valid options: mm, m, in, tenths" ) ) );
191 .default_value( std::string(
"" ) )
193 _(
"Name of folder to create and store 3d models in, if not specified or "
194 "empty, the models will be embedded in main exported VRML file" ) ) );
197 .help(
UTF8STDSTR(
_(
"Used with --models-dir to output relative paths in the "
198 "resulting file" ) ) )
239 step->SetOutputPath( m_argOutput );
241 step->m_filename = m_argInput;
242 step->m_format = m_format;
243 step->SetVarOverrides( m_argDefineVars );
249 if( format == wxS(
"step" ) )
251 else if( format == wxS(
"brep" ) )
253 else if( format == wxS(
"xao" ) )
255 else if( format == wxS(
"glb" ) )
259 wxFprintf( stderr,
_(
"Invalid format specified\n" ) );
268 if( units == wxS(
"in" ) )
270 else if( units == wxS(
"mm" ) )
272 else if( units == wxS(
"m" ) )
274 else if( units == wxS(
"tenths" ) )
278 wxFprintf( stderr,
_(
"Invalid units specified\n" ) );
291 if( !userOrigin.IsEmpty() )
294 std::regex_constants::icase );
296 std::string str( userOrigin.ToUTF8() );
297 std::regex_search( str, sm, re_pattern );
298 step->m_3dparams.m_Origin.x = atof( sm.str( 1 ).c_str() );
299 step->m_3dparams.m_Origin.y = atof( sm.str( 2 ).c_str() );
303 step->m_3dparams.m_Origin.x =
pcbIUScale.
mmToIU( step->m_3dparams.m_Origin.x );
304 step->m_3dparams.m_Origin.y =
pcbIUScale.
mmToIU( step->m_3dparams.m_Origin.y );
306 std::string tunit( sm[3] );
308 if( tunit.size() > 0 )
310 if( ( !sm.str( 1 ).compare(
" " ) || !sm.str( 2 ).compare(
" " ) )
311 || ( sm.size() != 4 ) )
313 std::cout << m_argParser;
318 if( !tunit.compare(
"in" ) || !tunit.compare(
"inch" ) )
320 step->m_3dparams.m_Origin *= 25.4;
322 else if( tunit.compare(
"mm" ) )
324 std::cout << m_argParser;
329 step->m_hasUserOrigin =
true;
336 wxString minDistance =
339 if( !minDistance.IsEmpty() )
343 std::string str( minDistance.ToUTF8() );
344 std::regex_search( str, sm, re_pattern );
345 step->m_3dparams.m_BoardOutlinesChainingEpsilon = atof( sm.str( 1 ).c_str() );
347 std::string tunit( sm[2] );
349 if( tunit.size() > 0 )
351 if( !tunit.compare(
"in" ) || !tunit.compare(
"inch" ) )
353 step->m_3dparams.m_BoardOutlinesChainingEpsilon *= 25.4;
355 else if( tunit.compare(
"mm" ) )
357 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