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_NO_BOARD_BODY "--no-board-body"
41#define ARG_NO_COMPONENTS "--no-components"
42#define ARG_INCLUDE_TRACKS "--include-tracks"
43#define ARG_INCLUDE_ZONES "--include-zones"
44#define ARG_INCLUDE_INNER_COPPER "--include-inner-copper"
45#define ARG_FUSE_SHAPES "--fuse-shapes"
46#define ARG_NO_OPTIMIZE_STEP "--no-optimize-step"
47#define ARG_NET_FILTER "--net-filter"
48#define ARG_FORMAT "--format"
49#define ARG_VRML_UNITS "--units"
50#define ARG_VRML_MODELS_DIR "--models-dir"
51#define ARG_VRML_MODELS_RELATIVE "--models-relative"
53#define REGEX_QUANTITY "([\\s]*[+-]?[\\d]*[.]?[\\d]*)"
54#define REGEX_DELIMITER "(?:[\\s]*x)"
55#define REGEX_UNIT "([m]{2}|(?:in))"
58 const std::string& aDescription,
70 .default_value( std::string(
"step" ) )
72 _(
"Output file format, options: step, brep, xao, glb (binary glTF)" ) ) );
81 _(
"Exclude 3D models for components with 'Unspecified' footprint type" ) ) )
82 .implicit_value(
true )
83 .default_value(
false );
87 _(
"Exclude 3D models for components with 'Do not populate' attribute" ) ) )
95 .help(
UTF8STDSTR(
_(
"Use Grid Origin for output origin" ) ) )
99 .help(
UTF8STDSTR(
_(
"Use Drill Origin for output origin" ) ) )
103 .help(
UTF8STDSTR(
_(
"Substitute STEP or IGS models with the same name in place "
104 "of VRML models" ) ) )
108 .help(
UTF8STDSTR(
_(
"Only generate a board with no components" ) ) )
116 .help(
UTF8STDSTR(
_(
"Exclude 3D models for components" ) ) )
128 .help(
UTF8STDSTR(
_(
"Export elements on inner copper layers" ) ) )
132 .help(
UTF8STDSTR(
_(
"Fuse overlapping geometry together" ) ) )
136 .default_value( std::string(
"0.01mm" ) )
138 _(
"Minimum distance between points to treat them as separate ones" ) ) )
139 .metavar(
"MIN_DIST" );
142 .default_value( std::string() )
144 "Only include copper items belonging to nets matching this wildcard" ) ) );
150 .help(
UTF8STDSTR(
_(
"Do not optimize STEP file (enables writing parametric "
156 .default_value( std::string() )
157 .help(
UTF8STDSTR(
_(
"User-specified output origin ex. 1x1in, 1x1inch, 25.4x25.4mm "
158 "(default unit mm)" ) ) );
163 .default_value( std::string(
"in" ) )
165 _(
"Output units; valid options: mm, m, in, tenths" ) ) );
168 .default_value( std::string(
"" ) )
170 _(
"Name of folder to create and store 3d models in, if not specified or "
171 "empty, the models will be embedded in main exported VRML file" ) ) );
174 .help(
UTF8STDSTR(
_(
"Used with --models-dir to output relative paths in the "
175 "resulting file" ) ) )
207 step->m_includeDNP = !m_argParser.get<
bool>(
ARG_NO_DNP );
208 step->m_overwrite = m_argParser.get<
bool>(
ARG_FORCE );
209 step->m_filename = m_argInput;
210 step->m_outputFile = m_argOutput;
211 step->m_format = m_format;
212 step->SetVarOverrides( m_argDefineVars );
218 if( format == wxS(
"step" ) )
220 else if( format == wxS(
"brep" ) )
222 else if( format == wxS(
"xao" ) )
224 else if( format == wxS(
"glb" ) )
228 wxFprintf( stderr,
_(
"Invalid format specified\n" ) );
237 if( units == wxS(
"in" ) )
239 else if( units == wxS(
"mm" ) )
241 else if( units == wxS(
"m" ) )
243 else if( units == wxS(
"tenths" ) )
247 wxFprintf( stderr,
_(
"Invalid units specified\n" ) );
260 if( !userOrigin.IsEmpty() )
263 std::regex_constants::icase );
265 std::string str( userOrigin.ToUTF8() );
266 std::regex_search( str, sm, re_pattern );
267 step->m_xOrigin = atof( sm.str( 1 ).c_str() );
268 step->m_yOrigin = atof( sm.str( 2 ).c_str() );
275 std::string tunit( sm[3] );
277 if( tunit.size() > 0 )
279 if( ( !sm.str( 1 ).compare(
" " ) || !sm.str( 2 ).compare(
" " ) )
280 || ( sm.size() != 4 ) )
282 std::cout << m_argParser;
287 if( !tunit.compare(
"in" ) || !tunit.compare(
"inch" ) )
289 step->m_xOrigin *= 25.4;
290 step->m_yOrigin *= 25.4;
292 else if( tunit.compare(
"mm" ) )
294 std::cout << m_argParser;
299 step->m_hasUserOrigin =
true;
306 wxString minDistance =
309 if( !minDistance.IsEmpty() )
313 std::string str( minDistance.ToUTF8() );
314 std::regex_search( str, sm, re_pattern );
315 step->m_BoardOutlinesChainingEpsilon = atof( sm.str( 1 ).c_str() );
317 std::string tunit( sm[2] );
319 if( tunit.size() > 0 )
321 if( !tunit.compare(
"in" ) || !tunit.compare(
"inch" ) )
323 step->m_BoardOutlinesChainingEpsilon *= 25.4;
325 else if( tunit.compare(
"mm" ) )
327 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