25#include <wx/choicdlg.h>
27#include <wx/stdpaths.h>
28#include <wx/process.h>
133 brdFile.SetExt( wxT(
"step" ) );
134 path = brdFile.GetFullPath();
138 wxSizerItem* sizer_item =
bSizerTop->GetItem( 1UL );
139 wxWindow* widget = sizer_item->GetWindow();
144 _(
"Select a STEP export filename" ),
147 wxSize( -1, -1 ), wxFLP_SAVE | wxFLP_USE_TEXTCTRL );
183 tmpStr = wxEmptyString;
188 size_t bad_count = 0;
195 if( model.m_Scale.x != 1.0 ||
196 model.m_Scale.y != 1.0 ||
197 model.m_Scale.z != 1.0 )
199 bad_scales.Append( wxS(
"\n") );
200 bad_scales.Append( model.m_Filename );
209 if( !bad_scales.empty()
210 && !
Pgm().GetCommonSettings()->m_DoNotShowAgain.scaled_3d_models_warning )
212 wxString extendedMsg =
_(
"Non-unity scaled models:" ) + wxT(
"\n" ) + bad_scales;
215 "Model scaling is not reliable for mechanical export." ),
216 _(
"Model Scale Warning" ), wxOK | wxICON_WARNING );
217 msgDlg.SetExtendedMessage( extendedMsg );
223 Pgm().GetCommonSettings()->m_DoNotShowAgain.scaled_3d_models_warning =
true;
285 "Please save the PCB and try again" ) );
325 case 0: tolerance = 0.001;
break;
327 case 1: tolerance = 0.01;
break;
328 case 2: tolerance = 0.1;
break;
341 chainingEpsilon,
nullptr );
345 _(
"Board outline is missing or not closed using %.3f mm tolerance.\n"
346 "Run DRC for a full analysis." ), tolerance ) );
354 msg.Printf(
_(
"File '%s' already exists. Do you want overwrite this file?" ),
357 if( wxMessageBox( msg,
_(
"STEP Export" ), wxYES_NO | wxICON_QUESTION,
this ) == wxNO )
361 wxFileName appK2S( wxStandardPaths::Get().GetExecutablePath() );
364 if( appK2S.GetPath().Find(
"/Contents/Applications/pcbnew.app/Contents/MacOS" ) != wxNOT_FOUND )
366 appK2S.AppendDir( wxT(
".." ) );
367 appK2S.AppendDir( wxT(
".." ) );
368 appK2S.AppendDir( wxT(
".." ) );
369 appK2S.AppendDir( wxT(
".." ) );
370 appK2S.AppendDir( wxT(
"MacOS" ) );
373 if( wxGetEnv( wxT(
"KICAD_RUN_FROM_BUILD_DIR" ),
nullptr ) )
375 appK2S.RemoveLastDir();
376 appK2S.AppendDir(
"kicad" );
380 appK2S.SetName( wxT(
"kicad-cli" ) );
383 wxString cmdK2S = wxT(
"\"" );
384 cmdK2S.Append( appK2S.GetFullPath() );
385 cmdK2S.Append( wxT(
"\"" ) );
387 cmdK2S.Append( wxT(
" pcb" ) );
388 cmdK2S.Append( wxT(
" export" ) );
389 cmdK2S.Append( wxT(
" step" ) );
392 cmdK2S.Append( wxT(
" --no-virtual" ) );
395 cmdK2S.Append( wxT(
" --subst-models" ) );
405 wxFAIL_MSG( wxT(
"Unsupported origin option: how did we get here?" ) );
409 cmdK2S.Append( wxT(
" --drill-origin" ) );
413 cmdK2S.Append( wxT(
" --grid-origin" ) );
430 quote, xOrg, yOrg, quote ) );
442 quote, xOrg, yOrg, quote ) );
450 quote, tolerance, quote ) );
461 wxLogTrace(
traceKiCad2Step, wxT(
"export step command: %s" ), cmdK2S );
constexpr EDA_IU_SCALE pcbIUScale
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.
wxStdDialogButtonSizer * m_sdbSizer
wxCheckBox * m_cbSubstModels
TEXT_CTRL_EVAL * m_STEP_Xorg
TEXT_CTRL_EVAL * m_STEP_Yorg
wxRadioButton * m_rbGridOrigin
wxCheckBox * m_cbOverwriteFile
wxFilePickerCtrl * m_filePickerSTEP
wxBoxSizer * bSizerSTEPFile
wxRadioButton * m_rbBoardCenterOrigin
wxChoice * m_STEP_OrgUnitChoice
wxCheckBox * m_cbRemoveVirtual
wxButton * m_sdbSizerCancel
wxRadioButton * m_rbUserDefinedOrigin
wxRadioButton * m_rbDrillAndPlotOrigin
STEP_ORIGIN_OPTION GetOriginOption()
int GetOrgUnitsChoice() const
@ STEP_ORIGIN_BOARD_CENTER
PCB_EDIT_FRAME * m_parent
void onUpdateXPos(wxUpdateUIEvent &aEvent) override
STEP_ORIGIN_OPTION m_origin
void onExportButton(wxCommandEvent &aEvent) override
DIALOG_EXPORT_STEP(PCB_EDIT_FRAME *aParent, const wxString &aBoardPath)
static int m_toleranceLastChoice
void onUpdateUnits(wxUpdateUIEvent &aEvent) override
void onUpdateYPos(wxUpdateUIEvent &aEvent) override
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.
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.
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)
Extracts the board outlines and build a closed polygon from lines, arcs and circle items on edge cut ...
wxString AddFileExtListToFilter(const std::vector< std::string > &aExts)
Build the wildcard extension file dialog wildcard filter to add to the base message dialog.
const wxChar *const traceKiCad2Step
Flag to enable KiCad2Step debug tracing.
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.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
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().