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_ZONES "--include-zones"
45#define ARG_INCLUDE_INNER_COPPER "--include-inner-copper"
46#define ARG_FUSE_SHAPES "--fuse-shapes"
47#define ARG_NO_OPTIMIZE_STEP "--no-optimize-step"
48#define ARG_NET_FILTER "--net-filter"
49#define ARG_FORMAT "--format"
50#define ARG_VRML_UNITS "--units"
51#define ARG_VRML_MODELS_DIR "--models-dir"
52#define ARG_VRML_MODELS_RELATIVE "--models-relative"
54#define REGEX_QUANTITY "([\\s]*[+-]?[\\d]*[.]?[\\d]*)"
55#define REGEX_DELIMITER "(?:[\\s]*x)"
56#define REGEX_UNIT "([m]{2}|(?:in))"
59 const std::string& aDescription,
71 .default_value( std::string(
"step" ) )
73 _(
"Output file format, options: step, brep, xao, glb (binary glTF)" ) ) );
82 _(
"Exclude 3D models for components with 'Unspecified' footprint type" ) ) )
83 .implicit_value(
true )
84 .default_value(
false );
88 _(
"Exclude 3D models for components with 'Do not populate' attribute" ) ) )
96 .help(
UTF8STDSTR(
_(
"Use Grid Origin for output origin" ) ) )
100 .help(
UTF8STDSTR(
_(
"Use Drill Origin for output origin" ) ) )
104 .help(
UTF8STDSTR(
_(
"Substitute STEP or IGS models with the same name in place "
105 "of VRML models" ) ) )
109 .help(
UTF8STDSTR(
_(
"Only generate a board with no components" ) ) )
117 .help(
UTF8STDSTR(
_(
"Exclude 3D models for components" ) ) )
129 .help(
UTF8STDSTR(
_(
"Export elements on inner copper layers" ) ) )
133 .help(
UTF8STDSTR(
_(
"Fuse overlapping geometry together" ) ) )
137 .default_value( std::string(
"0.01mm" ) )
139 _(
"Minimum distance between points to treat them as separate ones" ) ) )
140 .metavar(
"MIN_DIST" );
143 .default_value( std::string() )
145 "Only include copper items belonging to nets matching this wildcard" ) ) );
151 .help(
UTF8STDSTR(
_(
"Do not optimize STEP file (enables writing parametric "
157 .default_value( std::string() )
158 .help(
UTF8STDSTR(
_(
"User-specified output origin ex. 1x1in, 1x1inch, 25.4x25.4mm "
159 "(default unit mm)" ) ) );
164 .default_value( std::string(
"in" ) )
166 _(
"Output units; valid options: mm, m, in, tenths" ) ) );
169 .default_value( std::string(
"" ) )
171 _(
"Name of folder to create and store 3d models in, if not specified or "
172 "empty, the models will be embedded in main exported VRML file" ) ) );
175 .help(
UTF8STDSTR(
_(
"Used with --models-dir to output relative paths in the "
176 "resulting file" ) ) )
208 step->m_includeDNP = !m_argParser.get<
bool>(
ARG_NO_DNP );
209 step->m_overwrite = m_argParser.get<
bool>(
ARG_FORCE );
210 step->m_filename = m_argInput;
211 step->m_outputFile = m_argOutput;
212 step->m_format = m_format;
213 step->SetVarOverrides( m_argDefineVars );
219 if( format == wxS(
"step" ) )
221 else if( format == wxS(
"brep" ) )
223 else if( format == wxS(
"xao" ) )
225 else if( format == wxS(
"glb" ) )
229 wxFprintf( stderr,
_(
"Invalid format specified\n" ) );
238 if( units == wxS(
"in" ) )
240 else if( units == wxS(
"mm" ) )
242 else if( units == wxS(
"m" ) )
244 else if( units == wxS(
"tenths" ) )
248 wxFprintf( stderr,
_(
"Invalid units specified\n" ) );
261 if( !userOrigin.IsEmpty() )
264 std::regex_constants::icase );
266 std::string str( userOrigin.ToUTF8() );
267 std::regex_search( str, sm, re_pattern );
268 step->m_xOrigin = atof( sm.str( 1 ).c_str() );
269 step->m_yOrigin = atof( sm.str( 2 ).c_str() );
276 std::string tunit( sm[3] );
278 if( tunit.size() > 0 )
280 if( ( !sm.str( 1 ).compare(
" " ) || !sm.str( 2 ).compare(
" " ) )
281 || ( sm.size() != 4 ) )
283 std::cout << m_argParser;
288 if( !tunit.compare(
"in" ) || !tunit.compare(
"inch" ) )
290 step->m_xOrigin *= 25.4;
291 step->m_yOrigin *= 25.4;
293 else if( tunit.compare(
"mm" ) )
295 std::cout << m_argParser;
300 step->m_hasUserOrigin =
true;
307 wxString minDistance =
310 if( !minDistance.IsEmpty() )
314 std::string str( minDistance.ToUTF8() );
315 std::regex_search( str, sm, re_pattern );
316 step->m_BoardOutlinesChainingEpsilon = atof( sm.str( 1 ).c_str() );
318 std::string tunit( sm[2] );
320 if( tunit.size() > 0 )
322 if( !tunit.compare(
"in" ) || !tunit.compare(
"inch" ) )
324 step->m_BoardOutlinesChainingEpsilon *= 25.4;
326 else if( tunit.compare(
"mm" ) )
328 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.
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_INCLUDE_INNER_COPPER
#define ARG_VRML_MODELS_RELATIVE
#define ARG_NO_OPTIMIZE_STEP
#define ARG_NO_BOARD_BODY
#define ARG_NO_COMPONENTS
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