26#include <wx/stdpaths.h>
27#include <wx/process.h>
29#include <wx/filedlg.h>
141 { wxID_CANCEL,
_(
"Close" ) } } );
150 brdFile.SetExt( wxT(
"step" ) );
151 path = brdFile.GetFullPath();
192 tmpStr = wxEmptyString;
197 size_t bad_count = 0;
203 if( model.m_Scale.x != 1.0 || model.m_Scale.y != 1.0 || model.m_Scale.z != 1.0 )
205 bad_scales.Append( wxS(
"\n") );
206 bad_scales.Append( model.m_Filename );
215 if( !bad_scales.empty()
216 && !
Pgm().GetCommonSettings()->m_DoNotShowAgain.scaled_3d_models_warning )
218 wxString extendedMsg =
_(
"Non-unity scaled models:" ) + wxT(
"\n" ) + bad_scales;
221 "Model scaling is not reliable for mechanical export." ),
222 _(
"Model Scale Warning" ), wxOK | wxICON_WARNING );
223 msgDlg.SetExtendedMessage( extendedMsg );
229 Pgm().GetCommonSettings()->m_DoNotShowAgain.scaled_3d_models_warning =
true;
250 catch(
const std::runtime_error& e )
252 wxFAIL_MSG( e.what() );
307 "Please save the PCB and try again" ) );
340 wxString
filter =
_(
"STEP files" )
342 +
_(
"Binary GTLF files" )
347 wxFileName fn(
Prj().AbsolutePath(
path ) );
349 wxFileDialog dlg(
this,
_(
"STEP Output File" ), fn.GetPath(), fn.GetFullName(),
filter,
352 if( dlg.ShowModal() == wxID_CANCEL )
380 case 0: tolerance = 0.001;
break;
382 case 1: tolerance = 0.01;
break;
383 case 2: tolerance = 0.1;
break;
396 chainingEpsilon,
nullptr );
400 _(
"Board outline is missing or not closed using %.3f mm tolerance.\n"
401 "Run DRC for a full analysis." ), tolerance ) );
405 wxFileName fn(
Prj().AbsolutePath(
path ) );
409 msg.Printf(
_(
"File '%s' already exists. Do you want overwrite this file?" ),
412 if( wxMessageBox( msg,
_(
"STEP/GLTF Export" ), wxYES_NO | wxICON_QUESTION,
this ) == wxNO )
416 wxFileName appK2S( wxStandardPaths::Get().GetExecutablePath() );
419 if( appK2S.GetPath().Find(
"/Contents/Applications/pcbnew.app/Contents/MacOS" ) != wxNOT_FOUND )
421 appK2S.AppendDir( wxT(
".." ) );
422 appK2S.AppendDir( wxT(
".." ) );
423 appK2S.AppendDir( wxT(
".." ) );
424 appK2S.AppendDir( wxT(
".." ) );
425 appK2S.AppendDir( wxT(
"MacOS" ) );
428 if( wxGetEnv( wxT(
"KICAD_RUN_FROM_BUILD_DIR" ),
nullptr ) )
430 appK2S.RemoveLastDir();
431 appK2S.AppendDir(
"kicad" );
435 appK2S.SetName( wxT(
"kicad-cli" ) );
438 wxString cmdK2S = wxT(
"\"" );
439 cmdK2S.Append( appK2S.GetFullPath() );
440 cmdK2S.Append( wxT(
"\"" ) );
442 cmdK2S.Append( wxT(
" pcb" ) );
443 cmdK2S.Append( wxT(
" export" ) );
446 cmdK2S.Append( wxT(
" glb" ) );
448 cmdK2S.Append( wxT(
" step" ) );
451 cmdK2S.Append( wxT(
" --no-unspecified" ) );
454 cmdK2S.Append( wxT(
" --no-dnp" ) );
457 cmdK2S.Append( wxT(
" --subst-models" ) );
460 cmdK2S.Append( wxT(
" --no-optimize-step" ) );
463 cmdK2S.Append( wxT(
" --include-tracks" ) );
466 cmdK2S.Append( wxT(
" --include-zones" ) );
476 wxFAIL_MSG( wxT(
"Unsupported origin option: how did we get here?" ) );
480 cmdK2S.Append( wxT(
" --drill-origin" ) );
484 cmdK2S.Append( wxT(
" --grid-origin" ) );
500 cmdK2S.Append( wxString::Format( wxT(
" --user-origin=%c%.6fx%.6fmm%c" ),
501 quote, xOrg, yOrg, quote ) );
512 cmdK2S.Append( wxString::Format( wxT(
" --user-origin=%c%.6fx%.6fmm%c" ),
513 quote, xOrg, yOrg, quote ) );
520 cmdK2S.Append( wxString::Format( wxT(
" --min-distance=%c%.3fmm%c" ),
521 quote, tolerance, quote ) );
525 cmdK2S.Append( wxString::Format( wxT(
" -f -o %c%s%c" ),
526 dblquote, fn.GetFullPath(), dblquote ) );
530 cmdK2S.Append( wxString::Format( wxT(
" %c%s%c" ), dblquote,
m_boardPath, dblquote ) );
532 wxLogTrace(
traceKiCad2Step, wxT(
"export step command: %s" ), cmdK2S );
constexpr EDA_IU_SCALE pcbIUScale
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
BOX2I ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
FOOTPRINTS & Footprints()
const wxString & GetFileName() const
const Vec GetCenter() const
Class DIALOG_EXPORT_STEP_BASE.
wxCheckBox * m_cbExportTracks
wxCheckBox * m_cbSubstModels
TEXT_CTRL_EVAL * m_STEP_Xorg
TEXT_CTRL_EVAL * m_STEP_Yorg
wxRadioButton * m_rbGridOrigin
wxCheckBox * m_cbRemoveUnspecified
wxCheckBox * m_cbOverwriteFile
wxCheckBox * m_cbRemoveDNP
wxBoxSizer * bSizerSTEPFile
wxCheckBox * m_cbOptimizeStep
wxRadioButton * m_rbBoardCenterOrigin
wxTextCtrl * m_outputFileName
wxChoice * m_choiceTolerance
wxChoice * m_STEP_OrgUnitChoice
wxCheckBox * m_cbExportZones
wxRadioButton * m_rbUserDefinedOrigin
wxRadioButton * m_rbDrillAndPlotOrigin
STD_BITMAP_BUTTON * m_browseButton
STEP_ORIGIN_OPTION GetOriginOption()
int GetOrgUnitsChoice() const
@ STEP_ORIGIN_BOARD_CENTER
PCB_EDIT_FRAME * m_parent
void onUpdateXPos(wxUpdateUIEvent &aEvent) override
static bool m_exportZones
STEP_ORIGIN_OPTION m_origin
void onExportButton(wxCommandEvent &aEvent) override
DIALOG_EXPORT_STEP(PCB_EDIT_FRAME *aParent, const wxString &aBoardPath)
static int m_toleranceLastChoice
static bool m_optimizeStep
void onUpdateUnits(wxUpdateUIEvent &aEvent) override
bool GetNoUnspecifiedOption()
void onUpdateYPos(wxUpdateUIEvent &aEvent) override
static bool m_exportTracks
void onBrowseClicked(wxCommandEvent &aEvent) override
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
static wxString GetAutoSaveFilePrefix()
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
bool DoNotShowAgain() const
void DoNotShowCheckbox(wxString file, int line)
Checks the 'do not show again' setting for the dialog.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
DIALOG_EXPORT_STEP m_ExportStep
PCBNEW_SETTINGS * GetPcbNewSettings() const
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
The main frame for Pcbnew.
void SetLastPath(LAST_PATH_TYPE aType, const wxString &aLastPath)
Set the path of the last file successfully read.
bool doAutoSave() override
Perform auto save when the board has been modified and not saved within the auto save interval.
void OnExportSTEP(wxCommandEvent &event)
Export the current BOARD to a STEP assembly.
wxString GetLastPath(LAST_PATH_TYPE aType)
Get the last path for a particular type.
bool IsContentModified() const override
Get if the current board has been modified but not saved.
Represent a set of closed polygons.
void SetValue(const wxString &aValue) override
Set a new value in evaluator buffer, and display it in the wxTextCtrl.
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject)
Replace any environment variable & text variable references with their values.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
bool BuildBoardPolygonOutlines(BOARD *aBoard, SHAPE_POLY_SET &aOutlines, int aErrorMax, int aChainingEpsilon, OUTLINE_ERROR_HANDLER *aErrorHandler, bool aAllowUseArcsInPolygons)
Extract the board outlines and build a closed polygon from lines, arcs and circle items on edge cut l...
const std::string StepFileExtension
wxString AddFileExtListToFilter(const std::vector< std::string > &aExts)
Build the wildcard extension file dialog wildcard filter to add to the base message dialog.
const std::string StepFileAbrvExtension
const std::string GltfBinaryFileExtension
const wxChar *const traceKiCad2Step
Flag to enable KiCad2Step debug tracing.
KICOMMON_API double DoubleValueFromString(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Function DoubleValueFromString converts aTextValue to a double.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
std::vector< FAB_LAYER_COLOR > dummy
constexpr double IUTomm(int iu) const
constexpr int mmToIU(double mm) const
wxLogTrace helper definitions.
Definition of file extensions used in Kicad.
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().