26#include <wx/stdpaths.h>
27#include <wx/process.h>
29#include <wx/filedlg.h>
175 { wxID_CANCEL,
_(
"Close" ) } } );
184 brdFile.SetExt( wxT(
"step" ) );
185 path = brdFile.GetFullPath();
234 tmpStr = wxEmptyString;
239 size_t bad_count = 0;
245 if( model.m_Scale.x != 1.0 || model.m_Scale.y != 1.0 || model.m_Scale.z != 1.0 )
247 bad_scales.Append( wxS(
"\n") );
248 bad_scales.Append( model.m_Filename );
257 if( !bad_scales.empty()
260 wxString extendedMsg =
_(
"Non-unity scaled models:" ) + wxT(
"\n" ) + bad_scales;
263 "Model scaling is not reliable for mechanical export." ),
264 _(
"Model Scale Warning" ), wxOK | wxICON_WARNING );
265 msgDlg.SetExtendedMessage( extendedMsg );
295 catch(
const std::runtime_error& e )
297 wxFAIL_MSG( e.what() );
357 wxFileName autosaveProjFile;
364 "Please save the PCB and try again" ) );
373 autosaveProjFile = brdFile;
374 autosaveProjFile.SetName( autosaveFileName );
375 autosaveProjFile.SetExt(
"kicad_pro" );
379 brdFile.SetName( autosaveFileName );
386 if( !autosaveProjFile.GetFullPath().IsEmpty() )
387 wxRemoveFile( autosaveProjFile.GetFullPath() );
412 wxString
filter =
_(
"STEP files" )
414 +
_(
"Binary glTF files" )
418 +
_(
"BREP (OCCT) files" )
424 wxFileName fn(
Prj().AbsolutePath(
path ) );
426 wxFileDialog dlg(
this,
_(
"3D Model Output File" ), fn.GetPath(), fn.GetFullName(),
filter,
429 if( dlg.ShowModal() == wxID_CANCEL )
432 path = dlg.GetPath();
435 fn = wxFileName(
path );
447 int sepIdx = std::max(
path.Find(
'/',
true ),
path.Find(
'\\',
true ) );
448 int dotIdx =
path.Find(
'.',
true );
450 if( dotIdx == -1 || dotIdx < sepIdx )
451 path <<
'.' << newExt;
453 path =
path.Mid( 0, dotIdx ) <<
'.' << newExt;
465 std::function<bool( wxString* )> textResolver =
466 [&]( wxString* token ) ->
bool
499 case 0: tolerance = 0.001;
break;
501 case 1: tolerance = 0.01;
break;
502 case 2: tolerance = 0.1;
break;
515 chainingEpsilon,
nullptr );
519 _(
"Board outline is missing or not closed using %.3f mm tolerance.\n"
520 "Run DRC for a full analysis." ), tolerance ) );
524 wxFileName fn(
Prj().AbsolutePath(
path ) );
528 msg.Printf(
_(
"File '%s' already exists. Do you want overwrite this file?" ),
531 if( wxMessageBox( msg,
_(
"STEP/GLTF Export" ), wxYES_NO | wxICON_QUESTION,
this ) == wxNO )
535 wxFileName appK2S( wxStandardPaths::Get().GetExecutablePath() );
538 if( appK2S.GetPath().Find(
"/Contents/Applications/pcbnew.app/Contents/MacOS" ) != wxNOT_FOUND )
540 appK2S.AppendDir( wxT(
".." ) );
541 appK2S.AppendDir( wxT(
".." ) );
542 appK2S.AppendDir( wxT(
".." ) );
543 appK2S.AppendDir( wxT(
".." ) );
544 appK2S.AppendDir( wxT(
"MacOS" ) );
547 if( wxGetEnv( wxT(
"KICAD_RUN_FROM_BUILD_DIR" ),
nullptr ) )
549 appK2S.RemoveLastDir();
550 appK2S.AppendDir(
"kicad" );
554 appK2S.SetName( wxT(
"kicad-cli" ) );
557 wxString cmdK2S = wxT(
"\"" );
558 cmdK2S.Append( appK2S.GetFullPath() );
559 cmdK2S.Append( wxT(
"\"" ) );
561 cmdK2S.Append( wxT(
" pcb" ) );
562 cmdK2S.Append( wxT(
" export" ) );
564 cmdK2S.Append( wxT(
" " ) );
568 cmdK2S.Append( wxT(
" --no-unspecified" ) );
571 cmdK2S.Append( wxT(
" --no-dnp" ) );
574 cmdK2S.Append( wxT(
" --subst-models" ) );
577 cmdK2S.Append( wxT(
" --no-optimize-step" ) );
580 cmdK2S.Append( wxT(
" --no-board-body" ) );
583 cmdK2S.Append( wxT(
" --no-components" ) );
586 cmdK2S.Append( wxT(
" --include-tracks" ) );
589 cmdK2S.Append( wxT(
" --include-pads" ) );
592 cmdK2S.Append( wxT(
" --include-zones" ) );
595 cmdK2S.Append( wxT(
" --include-inner-copper" ) );
598 cmdK2S.Append( wxT(
" --include-silkscreen" ) );
601 cmdK2S.Append( wxT(
" --include-soldermask" ) );
604 cmdK2S.Append( wxT(
" --fuse-shapes" ) );
613 cmdK2S.Append( wxString::Format( wxT(
" --net-filter %c%s%c" ), dblquote,
m_netFilter,
620 wxFAIL_MSG( wxT(
"Unsupported origin option: how did we get here?" ) );
624 cmdK2S.Append( wxT(
" --drill-origin" ) );
628 cmdK2S.Append( wxT(
" --grid-origin" ) );
644 cmdK2S.Append( wxString::Format( wxT(
" --user-origin=%c%.6fx%.6fmm%c" ),
645 quote, xOrg, yOrg, quote ) );
656 cmdK2S.Append( wxString::Format( wxT(
" --user-origin=%c%.6fx%.6fmm%c" ),
657 quote, xOrg, yOrg, quote ) );
664 cmdK2S.Append( wxString::Format( wxT(
" --min-distance=%c%.3fmm%c" ),
665 quote, tolerance, quote ) );
669 cmdK2S.Append( wxString::Format( wxT(
" -f -o %c%s%c" ),
670 dblquote, fn.GetFullPath(), dblquote ) );
674 cmdK2S.Append( wxString::Format( wxT(
" %c%s%c" ), dblquote,
m_boardPath, dblquote ) );
676 wxLogTrace(
traceKiCad2Step, wxT(
"export step command: %s" ), cmdK2S );
constexpr EDA_IU_SCALE pcbIUScale
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
BOX2I ComputeBoundingBox(bool aBoardEdgesOnly=false, bool aIncludeHiddenText=false) const
Calculate the bounding box containing all board items (or board edge segments).
bool ResolveTextVar(wxString *token, int aDepth) const
const FOOTPRINTS & Footprints() const
const wxString & GetFileName() const
const Vec GetCenter() const
DO_NOT_SHOW_AGAIN m_DoNotShowAgain
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_cbExportBody
wxCheckBox * m_cbRemoveUnspecified
wxCheckBox * m_cbOverwriteFile
wxCheckBox * m_cbRemoveDNP
wxBoxSizer * bSizerSTEPFile
wxCheckBox * m_cbExportComponents
wxCheckBox * m_cbOptimizeStep
wxCheckBox * m_cbFuseShapes
wxRadioButton * m_rbBoardCenterOrigin
wxTextCtrl * m_outputFileName
wxCheckBox * m_cbExportInnerCopper
wxChoice * m_choiceTolerance
wxChoice * m_STEP_OrgUnitChoice
wxTextCtrl * m_txtNetFilter
wxCheckBox * m_cbExportSoldermask
wxCheckBox * m_cbExportPads
wxChoice * m_choiceFormat
wxCheckBox * m_cbExportZones
wxRadioButton * m_rbUserDefinedOrigin
wxCheckBox * m_cbExportSilkscreen
wxRadioButton * m_rbDrillAndPlotOrigin
STD_BITMAP_BUTTON * m_browseButton
void onFormatChoice(wxCommandEvent &event) override
STEP_ORIGIN_OPTION GetOriginOption()
static int m_formatLastChoice
static bool m_exportSoldermask
int GetOrgUnitsChoice() const
@ STEP_ORIGIN_BOARD_CENTER
PCB_EDIT_FRAME * m_parent
void onUpdateXPos(wxUpdateUIEvent &aEvent) override
static bool m_exportComponents
static bool m_exportZones
STEP_ORIGIN_OPTION m_origin
void onExportButton(wxCommandEvent &aEvent) override
static bool m_exportBoardBody
DIALOG_EXPORT_STEP(PCB_EDIT_FRAME *aParent, const wxString &aBoardPath)
static bool m_exportSilkscreen
static int m_toleranceLastChoice
static bool m_optimizeStep
void onUpdateUnits(wxUpdateUIEvent &aEvent) override
bool GetNoUnspecifiedOption()
static bool m_exportInnerCopper
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...
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.
virtual COMMON_SETTINGS * GetCommonSettings() const
virtual const wxString AbsolutePath(const wxString &aFileName) const
Fix up aFileName if it is relative to the project's directory to be an absolute path and filename.
void SaveProjectCopy(const wxString &aFullPath, PROJECT *aProject=nullptr)
Saves a copy of the current project under the given path.
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.
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
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...
static const std::map< wxString, int > c_formatExtToChoice
static const std::vector< wxString > c_formatCommand
static const std::string BrepFileExtension
static const std::string StepFileAbrvExtension
static const std::string XaoFileExtension
static const std::string GltfBinaryFileExtension
static const std::string AutoSaveFilePrefix
static const std::string StepFileExtension
const wxChar *const traceKiCad2Step
Flag to enable KiCad2Step debug tracing.
This file is part of the common library.
std::optional< V > get_opt(const std::map< wxString, V > &aMap, const wxString &aKey)
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.
SETTINGS_MANAGER * GetSettingsManager()
PGM_BASE & Pgm()
The global Program "get" accessor.
std::vector< FAB_LAYER_COLOR > dummy
bool scaled_3d_models_warning
constexpr double IUTomm(int iu) const
constexpr int mmToIU(double mm) const
wxLogTrace helper definitions.
wxString AddFileExtListToFilter(const std::vector< std::string > &aExts)
Build the wildcard extension file dialog wildcard filter to add to the base message dialog.
Definition of file extensions used in Kicad.
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().