KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_export_step.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2016 Cirilo Bernardo
5 * Copyright (C) 2016-2024 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <wx/log.h>
26#include <wx/stdpaths.h>
27#include <wx/process.h>
28#include <wx/string.h>
29#include <wx/filedlg.h>
30
31#include <pgm_base.h>
32#include <board.h>
33#include <confirm.h>
34#include <kidialog.h>
38#include <footprint.h>
39#include <kiface_base.h>
40#include <locale_io.h>
41#include <math/vector3.h>
42#include <pcb_edit_frame.h>
43#include <pcbnew_settings.h>
44#include <project/project_file.h> // LAST_PATH_TYPE
45#include <reporter.h>
46#include <trace_helpers.h>
49#include <filename_resolver.h>
50#include <core/map_helpers.h>
52
53
54// Maps m_choiceFormat selection to extension (and kicad-cli command)
55static const std::vector<wxString> c_formatCommand = { FILEEXT::StepFileExtension,
59
60// Maps file extensions to m_choiceFormat selection
61static const std::map<wxString, int> c_formatExtToChoice = { { FILEEXT::StepFileExtension, 0 },
66
67
69{
70public:
72 {
73 STEP_ORIGIN_0, // absolute coordinates
74 STEP_ORIGIN_PLOT_AXIS, // origin is plot/drill axis origin
75 STEP_ORIGIN_GRID_AXIS, // origin is grid origin
76 STEP_ORIGIN_BOARD_CENTER, // origin is board center
77 STEP_ORIGIN_USER, // origin is entered by user
78 };
79
80 DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aParent, const wxString& aBoardPath );
82
83protected:
84 void onBrowseClicked( wxCommandEvent& aEvent ) override;
85 void onUpdateUnits( wxUpdateUIEvent& aEvent ) override;
86 void onUpdateXPos( wxUpdateUIEvent& aEvent ) override;
87 void onUpdateYPos( wxUpdateUIEvent& aEvent ) override;
88 void onExportButton( wxCommandEvent& aEvent ) override;
89 void onFormatChoice( wxCommandEvent& event ) override;
90 void onCbExportComponents( wxCommandEvent& event ) override;
91 void OnComponentModeChange( wxCommandEvent& event ) override;
92
94 {
95 return m_STEP_OrgUnitChoice->GetSelection();
96 }
97
98 double GetXOrg() const
99 {
101 }
102
103 double GetYOrg()
104 {
106 }
107
109
111 {
112 return m_cbRemoveUnspecified->GetValue();
113 }
114
116 {
117 return m_cbRemoveDNP->GetValue();
118 }
119
121 {
122 return m_cbSubstModels->GetValue();
123 }
124
126 {
127 return m_cbOverwriteFile->GetValue();
128 }
129
130 // Called to update filename extension after the output file format is changed
132
133private:
134 enum class COMPONENT_MODE
135 {
139 };
140
142 STEP_ORIGIN_OPTION m_origin; // The last preference for STEP origin option
143 double m_userOriginX; // remember last User Origin X value
144 double m_userOriginY; // remember last User Origin Y value
145 int m_originUnits; // remember last units for User Origin
146 bool m_noUnspecified; // remember last preference for No Unspecified Component
147 bool m_noDNP; // remember last preference for No DNP Component
148 static bool m_optimizeStep; // remember last preference for Optimize STEP file (stored only for the session)
149 static bool m_exportBoardBody; // remember last preference to export board body (stored only for the session)
150 static bool m_exportComponents; // remember last preference to export components (stored only for the session)
151 static bool m_exportTracks; // remember last preference to export tracks and vias (stored only for the session)
152 static bool m_exportPads; // remember last preference to export pads (stored only for the session)
153 static bool m_exportZones; // remember last preference to export zones (stored only for the session)
154 static bool m_exportInnerCopper; // remember last preference to export inner layers (stored only for the session)
155 static bool m_exportSilkscreen; // remember last preference to export silkscreen (stored only for the session)
156 static bool m_exportSoldermask; // remember last preference to export soldermask (stored only for the session)
157 static bool m_fuseShapes; // remember last preference to fuse shapes (stored only for the session)
158 wxString m_netFilter; // filter copper nets
159 static wxString m_componentFilter; // filter component reference designators
161 wxString m_boardPath; // path to the exported board file
162 static int m_toleranceLastChoice; // Store m_tolerance option during a session
163 static int m_formatLastChoice; // Store format option during a session
164};
165
166
167int DIALOG_EXPORT_STEP::m_toleranceLastChoice = -1; // Use default
168int DIALOG_EXPORT_STEP::m_formatLastChoice = -1; // Use default
181
182DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aParent, const wxString& aBoardPath ) :
183 DIALOG_EXPORT_STEP_BASE( aParent )
184{
185 m_browseButton->SetBitmap( KiBitmapBundle( BITMAPS::small_folder ) );
186
187 m_parent = aParent;
188 m_boardPath = aBoardPath;
189
190 SetupStandardButtons( { { wxID_OK, _( "Export" ) },
191 { wxID_CANCEL, _( "Close" ) } } );
192
193 // Build default output file name
194 // (last saved filename in project or built from board filename)
196
197 if( path.IsEmpty() )
198 {
199 wxFileName brdFile( m_parent->GetBoard()->GetFileName() );
200 brdFile.SetExt( wxT( "step" ) );
201 path = brdFile.GetFullPath();
202 }
203
204 m_outputFileName->SetValue( path );
205
206 Layout();
207 bSizerSTEPFile->Fit( this );
208
209 SetFocus();
210
212
214
215 switch( m_origin )
216 {
217 default:
218 case STEP_ORIGIN_PLOT_AXIS: m_rbDrillAndPlotOrigin->SetValue( true ); break;
219 case STEP_ORIGIN_GRID_AXIS: m_rbGridOrigin->SetValue( true ); break;
220 case STEP_ORIGIN_USER: m_rbUserDefinedOrigin->SetValue( true ); break;
221 case STEP_ORIGIN_BOARD_CENTER: m_rbBoardCenterOrigin->SetValue( true ); break;
222 }
223
229
230 m_txtNetFilter->SetValue( m_netFilter );
231 m_cbOptimizeStep->SetValue( m_optimizeStep );
234 m_cbExportTracks->SetValue( m_exportTracks );
235 m_cbExportPads->SetValue( m_exportPads );
236 m_cbExportZones->SetValue( m_exportZones );
240 m_cbFuseShapes->SetValue( m_fuseShapes );
242 m_cbRemoveDNP->SetValue( m_noDNP );
245
247
248 switch( m_componentMode )
249 {
250 case COMPONENT_MODE::EXPORT_ALL: m_rbAllComponents->SetValue( true ); break;
251 case COMPONENT_MODE::EXPORT_SELECTED: m_rbOnlySelected->SetValue( true ); break;
252 case COMPONENT_MODE::CUSTOM_FILTER: m_rbFilteredComponents->SetValue( true ); break;
253 }
254
255 // Sync the enabled states
256 wxCommandEvent dummy;
258
259 m_STEP_OrgUnitChoice->SetSelection( m_originUnits );
260 wxString tmpStr;
261 tmpStr << m_userOriginX;
262 m_STEP_Xorg->SetValue( tmpStr );
263 tmpStr = wxEmptyString;
264 tmpStr << m_userOriginY;
265 m_STEP_Yorg->SetValue( tmpStr );
266
267 wxString bad_scales;
268 size_t bad_count = 0;
269
270 for( FOOTPRINT* fp : aParent->GetBoard()->Footprints() )
271 {
272 for( const FP_3DMODEL& model : fp->Models() )
273 {
274 if( model.m_Scale.x != 1.0 || model.m_Scale.y != 1.0 || model.m_Scale.z != 1.0 )
275 {
276 bad_scales.Append( wxS("\n") );
277 bad_scales.Append( model.m_Filename );
278 bad_count++;
279 }
280 }
281
282 if( bad_count >= 5 )
283 break;
284 }
285
286 if( !bad_scales.empty()
287 && !Pgm().GetCommonSettings()->m_DoNotShowAgain.scaled_3d_models_warning )
288 {
289 wxString extendedMsg = _( "Non-unity scaled models:" ) + wxT( "\n" ) + bad_scales;
290
291 KIDIALOG msgDlg( m_parent, _( "Scaled models detected. "
292 "Model scaling is not reliable for mechanical export." ),
293 _( "Model Scale Warning" ), wxOK | wxICON_WARNING );
294 msgDlg.SetExtendedMessage( extendedMsg );
295 msgDlg.DoNotShowCheckbox( __FILE__, __LINE__ );
296
297 msgDlg.ShowModal();
298
299 if( msgDlg.DoNotShowAgain() )
301 }
302
303 if( m_toleranceLastChoice >= 0 )
305
306 if( m_formatLastChoice >= 0 )
307 m_choiceFormat->SetSelection( m_formatLastChoice );
308 else
309 // ensure the selected fmt and the output file ext are synchronized the first time
310 // the dialog is opened
312
313 // Now all widgets have the size fixed, call FinishDialogSettings
315}
316
317
319{
320 GetOriginOption(); // Update m_origin member.
321
322 PCBNEW_SETTINGS* cfg = nullptr;
323
324 try
325 {
327 }
328 catch( const std::runtime_error& e )
329 {
330 wxFAIL_MSG( e.what() );
331 }
332
333 if( cfg )
334 {
335 cfg->m_ExportStep.origin_mode = static_cast<int>( m_origin );
336 cfg->m_ExportStep.origin_units = m_STEP_OrgUnitChoice->GetSelection();
339
340 double val = 0.0;
341
342 m_STEP_Xorg->GetValue().ToDouble( &val );
343 cfg->m_ExportStep.origin_x = val;
344
345 m_STEP_Yorg->GetValue().ToDouble( &val );
346 cfg->m_ExportStep.origin_y = val;
347
349 cfg->m_ExportStep.no_dnp = m_cbRemoveDNP->GetValue();
350 }
351
352 m_netFilter = m_txtNetFilter->GetValue();
354 m_formatLastChoice = m_choiceFormat->GetSelection();
355 m_optimizeStep = m_cbOptimizeStep->GetValue();
356 m_exportBoardBody = m_cbExportBody->GetValue();
358 m_exportTracks = m_cbExportTracks->GetValue();
359 m_exportPads = m_cbExportPads->GetValue();
360 m_exportZones = m_cbExportZones->GetValue();
364 m_fuseShapes = m_cbFuseShapes->GetValue();
366
367 if( m_rbAllComponents->GetValue() )
369 else if( m_rbOnlySelected->GetValue() )
371 else
373}
374
375
377{
379
380 if( m_rbDrillAndPlotOrigin->GetValue() )
382 else if( m_rbGridOrigin->GetValue() )
384 else if( m_rbUserDefinedOrigin->GetValue() )
386 else if( m_rbBoardCenterOrigin->GetValue() )
388
389 return m_origin;
390}
391
392
393void PCB_EDIT_FRAME::OnExportSTEP( wxCommandEvent& event )
394{
395 wxFileName brdFile = GetBoard()->GetFileName();
396
397 // The project filename (.kicad_pro) of the auto saved board filename, if it is created
398 wxFileName autosaveProjFile;
399
400 if( GetScreen()->IsContentModified() || brdFile.GetFullPath().empty() )
401 {
402 if( !doAutoSave() )
403 {
404 DisplayErrorMessage( this, _( "STEP export failed! "
405 "Please save the PCB and try again" ) );
406 return;
407 }
408
409 wxString autosaveFileName = FILEEXT::AutoSaveFilePrefix + brdFile.GetName();
410
411 // Create a dummy .kicad_pro file for this auto saved board file.
412 // this is useful to use some settings (like project path and name)
413 // Because doAutoSave() works, the target directory exists and is writable
414 autosaveProjFile = brdFile;
415 autosaveProjFile.SetName( autosaveFileName );
416 autosaveProjFile.SetExt( "kicad_pro" );
417
418 // Use auto-saved board for export
419 GetSettingsManager()->SaveProjectCopy( autosaveProjFile.GetFullPath(), GetBoard()->GetProject() );
420 brdFile.SetName( autosaveFileName );
421 }
422
423 DIALOG_EXPORT_STEP dlg( this, brdFile.GetFullPath() );
424 dlg.ShowModal();
425
426 // If a dummy .kicad_pro file is created, delete it now it is useless.
427 if( !autosaveProjFile.GetFullPath().IsEmpty() )
428 wxRemoveFile( autosaveProjFile.GetFullPath() );
429}
430
431
432void DIALOG_EXPORT_STEP::onUpdateUnits( wxUpdateUIEvent& aEvent )
433{
434 aEvent.Enable( m_rbUserDefinedOrigin->GetValue() );
435}
436
437
438void DIALOG_EXPORT_STEP::onUpdateXPos( wxUpdateUIEvent& aEvent )
439{
440 aEvent.Enable( m_rbUserDefinedOrigin->GetValue() );
441}
442
443
444void DIALOG_EXPORT_STEP::onUpdateYPos( wxUpdateUIEvent& aEvent )
445{
446 aEvent.Enable( m_rbUserDefinedOrigin->GetValue() );
447}
448
449
450void DIALOG_EXPORT_STEP::onBrowseClicked( wxCommandEvent& aEvent )
451{
452 // clang-format off
453 wxString filter = _( "STEP files" )
455 + _( "Binary glTF files" )
457 + _( "XAO files" )
459 + _( "BREP (OCCT) files" )
461 // clang-format on
462
463 // Build the absolute path of current output directory to preselect it in the file browser.
464 wxString path = ExpandEnvVarSubstitutions( m_outputFileName->GetValue(), &Prj() );
465 wxFileName fn( Prj().AbsolutePath( path ) );
466
467 wxFileDialog dlg( this, _( "3D Model Output File" ), fn.GetPath(), fn.GetFullName(), filter,
468 wxFD_SAVE );
469
470 if( dlg.ShowModal() == wxID_CANCEL )
471 return;
472
473 path = dlg.GetPath();
474 m_outputFileName->SetValue( path );
475
476 fn = wxFileName( path );
477
478 if( auto formatChoice = get_opt( c_formatExtToChoice, fn.GetExt().Lower() ) )
479 m_choiceFormat->SetSelection( *formatChoice );
480}
481
482
483void DIALOG_EXPORT_STEP::onFormatChoice( wxCommandEvent& event )
484{
486}
487
488
490{
491 wxString newExt = c_formatCommand[m_choiceFormat->GetSelection()];
492 wxString path = m_outputFileName->GetValue();
493
494 int sepIdx = std::max( path.Find( '/', true ), path.Find( '\\', true ) );
495 int dotIdx = path.Find( '.', true );
496
497 if( dotIdx == -1 || dotIdx < sepIdx )
498 path << '.' << newExt;
499 else
500 path = path.Mid( 0, dotIdx ) << '.' << newExt;
501
502 m_outputFileName->SetValue( path );
503}
504
505
506void DIALOG_EXPORT_STEP::onCbExportComponents( wxCommandEvent& event )
507{
508 bool enable = m_cbExportComponents->GetValue();
509
510 m_rbAllComponents->Enable( enable );
511 m_rbOnlySelected->Enable( enable );
512 m_rbFilteredComponents->Enable( enable );
513 m_txtComponentFilter->Enable( enable && m_rbFilteredComponents->GetValue() );
514}
515
516
517void DIALOG_EXPORT_STEP::OnComponentModeChange( wxCommandEvent& event )
518{
519 m_txtComponentFilter->Enable( m_rbFilteredComponents->GetValue() );
520}
521
522
523void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent )
524{
525 wxString path = m_outputFileName->GetValue();
527
528 // Build the absolute path of current output directory to preselect it in the file browser.
529 std::function<bool( wxString* )> textResolver =
530 [&]( wxString* token ) -> bool
531 {
532 return m_parent->GetBoard()->ResolveTextVar( token, 0 );
533 };
534
535 path = ExpandTextVars( path, &textResolver );
537 path = Prj().AbsolutePath( path );
538
539 if( path.IsEmpty() )
540 {
541 DisplayErrorMessage( this, _( "No filename for output file" ) );
542 return;
543 }
544
545 m_netFilter = m_txtNetFilter->GetValue();
547
548 if( m_rbAllComponents->GetValue() )
550 else if( m_rbOnlySelected->GetValue() )
552 else
554
555 double tolerance; // default value in mm
557 m_formatLastChoice = m_choiceFormat->GetSelection();
558 m_optimizeStep = m_cbOptimizeStep->GetValue();
559 m_exportBoardBody = m_cbExportBody->GetValue();
561 m_exportTracks = m_cbExportTracks->GetValue();
562 m_exportPads = m_cbExportPads->GetValue();
563 m_exportZones = m_cbExportZones->GetValue();
567 m_fuseShapes = m_cbFuseShapes->GetValue();
568
569 switch( m_choiceTolerance->GetSelection() )
570 {
571 case 0: tolerance = 0.001; break;
572 default:
573 case 1: tolerance = 0.01; break;
574 case 2: tolerance = 0.1; break;
575 }
576
577 SHAPE_POLY_SET outline;
578 wxString msg;
579
580 // Check if the board outline is continuous
581 // max dist from one endPt to next startPt to build a closed shape:
582 int chainingEpsilon = pcbIUScale.mmToIU( tolerance );
583
584 // Arc to segment approx error (not critical here: we do not use the outline shape):
585 int maxError = pcbIUScale.mmToIU( 0.005 );
586 bool success = BuildBoardPolygonOutlines( m_parent->GetBoard(), outline, maxError,
587 chainingEpsilon, nullptr );
588 if( !success )
589 {
590 DisplayErrorMessage( this, wxString::Format(
591 _( "Board outline is missing or not closed using %.3f mm tolerance.\n"
592 "Run DRC for a full analysis." ), tolerance ) );
593 return;
594 }
595
596 wxFileName fn( Prj().AbsolutePath( path ) );
597
598 if( fn.FileExists() && !GetOverwriteFile() )
599 {
600 msg.Printf( _( "File '%s' already exists. Do you want overwrite this file?" ),
601 fn.GetFullPath() );
602
603 if( wxMessageBox( msg, _( "STEP/GLTF Export" ), wxYES_NO | wxICON_QUESTION, this ) == wxNO )
604 return;
605 }
606
607 wxFileName appK2S( wxStandardPaths::Get().GetExecutablePath() );
608#ifdef __WXMAC__
609 // On macOS, we have standalone applications inside the main bundle, so we handle that here:
610 if( appK2S.GetPath().Find( "/Contents/Applications/pcbnew.app/Contents/MacOS" ) != wxNOT_FOUND )
611 {
612 appK2S.AppendDir( wxT( ".." ) );
613 appK2S.AppendDir( wxT( ".." ) );
614 appK2S.AppendDir( wxT( ".." ) );
615 appK2S.AppendDir( wxT( ".." ) );
616 appK2S.AppendDir( wxT( "MacOS" ) );
617 }
618#else
619 if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) )
620 {
621 appK2S.RemoveLastDir();
622 appK2S.AppendDir( "kicad" );
623 }
624#endif
625
626 appK2S.SetName( wxT( "kicad-cli" ) );
627 appK2S.Normalize( FN_NORMALIZE_FLAGS );
628
629 wxString cmdK2S = wxT( "\"" );
630 cmdK2S.Append( appK2S.GetFullPath() );
631 cmdK2S.Append( wxT( "\"" ) );
632
633 cmdK2S.Append( wxT( " pcb" ) );
634 cmdK2S.Append( wxT( " export" ) );
635
636 cmdK2S.Append( wxT( " " ) );
637 cmdK2S.Append( c_formatCommand[m_choiceFormat->GetSelection()] );
638
640 cmdK2S.Append( wxT( " --no-unspecified" ) );
641
642 if( GetNoDNPOption() )
643 cmdK2S.Append( wxT( " --no-dnp" ) );
644
645 if( GetSubstOption() )
646 cmdK2S.Append( wxT( " --subst-models" ) );
647
648 if( !m_optimizeStep )
649 cmdK2S.Append( wxT( " --no-optimize-step" ) );
650
651 if( !m_exportBoardBody )
652 cmdK2S.Append( wxT( " --no-board-body" ) );
653
654 if( !m_exportComponents )
655 cmdK2S.Append( wxT( " --no-components" ) );
656
657 if( m_exportTracks )
658 cmdK2S.Append( wxT( " --include-tracks" ) );
659
660 if( m_exportPads )
661 cmdK2S.Append( wxT( " --include-pads" ) );
662
663 if( m_exportZones )
664 cmdK2S.Append( wxT( " --include-zones" ) );
665
667 cmdK2S.Append( wxT( " --include-inner-copper" ) );
668
670 cmdK2S.Append( wxT( " --include-silkscreen" ) );
671
673 cmdK2S.Append( wxT( " --include-soldermask" ) );
674
675 if( m_fuseShapes )
676 cmdK2S.Append( wxT( " --fuse-shapes" ) );
677
678 // Note: for some reason, using \" to insert a quote in a format string, under MacOS
679 // wxString::Format does not work. So use a %c format in string
680 int quote = '\'';
681 int dblquote = '"';
682
683 if( !m_netFilter.empty() )
684 {
685 cmdK2S.Append( wxString::Format( wxT( " --net-filter %c%s%c" ), dblquote, m_netFilter,
686 dblquote ) );
687 }
688
689 switch( m_componentMode )
690 {
692 {
693 wxArrayString components;
694 SELECTION& selection = m_parent->GetCurrentSelection();
695
696 std::for_each( selection.begin(), selection.end(),
697 [&components]( EDA_ITEM* item )
698 {
699 if( item->Type() == PCB_FOOTPRINT_T )
700 components.push_back( static_cast<FOOTPRINT*>( item )->GetReference() );
701 } );
702
703 cmdK2S.Append( wxString::Format( wxT( " --component-filter %c%s%c" ), dblquote,
704 wxJoin( components, ',' ), dblquote ) );
705 break;
706 }
707
709 cmdK2S.Append( wxString::Format( wxT( " --component-filter %c%s%c" ), dblquote,
710 m_componentFilter, dblquote ) );
711 break;
712
713 default:
714 break;
715 }
716
717 switch( GetOriginOption() )
718 {
719 case STEP_ORIGIN_0:
720 wxFAIL_MSG( wxT( "Unsupported origin option: how did we get here?" ) );
721 break;
722
724 cmdK2S.Append( wxT( " --drill-origin" ) );
725 break;
726
728 cmdK2S.Append( wxT( " --grid-origin" ) );
729 break;
730
731 case STEP_ORIGIN_USER:
732 {
733 double xOrg = GetXOrg();
734 double yOrg = GetYOrg();
735
736 if( GetOrgUnitsChoice() == 1 )
737 {
738 // selected reference unit is in inches, and STEP units are mm
739 xOrg *= 25.4;
740 yOrg *= 25.4;
741 }
742
744 cmdK2S.Append( wxString::Format( wxT( " --user-origin=%c%.6fx%.6fmm%c" ),
745 quote, xOrg, yOrg, quote ) );
746 break;
747 }
748
750 {
751 BOX2I bbox = m_parent->GetBoard()->ComputeBoundingBox( true, false );
752 double xOrg = pcbIUScale.IUTomm( bbox.GetCenter().x );
753 double yOrg = pcbIUScale.IUTomm( bbox.GetCenter().y );
755
756 cmdK2S.Append( wxString::Format( wxT( " --user-origin=%c%.6fx%.6fmm%c" ),
757 quote, xOrg, yOrg, quote ) );
758 break;
759 }
760 }
761
762 {
764 cmdK2S.Append( wxString::Format( wxT( " --min-distance=%c%.3fmm%c" ),
765 quote, tolerance, quote ) );
766 }
767
768 // Output file path.
769 cmdK2S.Append( wxString::Format( wxT( " -f -o %c%s%c" ),
770 dblquote, fn.GetFullPath(), dblquote ) );
771
772
773 // Input file path.
774 cmdK2S.Append( wxString::Format( wxT( " %c%s%c" ), dblquote, m_boardPath, dblquote ) );
775
776 wxLogTrace( traceKiCad2Step, wxT( "export step command: %s" ), cmdK2S );
777
778 DIALOG_EXPORT_STEP_LOG* log = new DIALOG_EXPORT_STEP_LOG( this, cmdK2S );
779 log->ShowModal();
780}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
Definition: bitmap.cpp:110
BOX2I ComputeBoundingBox(bool aBoardEdgesOnly=false, bool aIncludeHiddenText=false) const
Calculate the bounding box containing all board items (or board edge segments).
Definition: board.cpp:1653
bool ResolveTextVar(wxString *token, int aDepth) const
Definition: board.cpp:431
const FOOTPRINTS & Footprints() const
Definition: board.h:330
const wxString & GetFileName() const
Definition: board.h:326
const Vec GetCenter() const
Definition: box2.h:220
DO_NOT_SHOW_AGAIN m_DoNotShowAgain
Class DIALOG_EXPORT_STEP_BASE.
wxRadioButton * m_rbFilteredComponents
wxRadioButton * m_rbDrillAndPlotOrigin
STD_BITMAP_BUTTON * m_browseButton
void onFormatChoice(wxCommandEvent &event) override
STEP_ORIGIN_OPTION GetOriginOption()
void onCbExportComponents(wxCommandEvent &event) override
void OnComponentModeChange(wxCommandEvent &event) override
PCB_EDIT_FRAME * m_parent
static COMPONENT_MODE m_componentMode
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 wxString m_componentFilter
void onUpdateUnits(wxUpdateUIEvent &aEvent) override
void onUpdateYPos(wxUpdateUIEvent &aEvent) override
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...
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: kidialog.h:43
bool DoNotShowAgain() const
Definition: kidialog.cpp:59
void DoNotShowCheckbox(wxString file, int line)
Checks the 'do not show again' setting for the dialog.
Definition: kidialog.cpp:51
int ShowModal() override
Definition: kidialog.cpp:95
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.
Definition: locale_io.h:49
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.
BOARD * GetBoard() const
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.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:678
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.
Definition: project.cpp:320
ITER end()
Definition: selection.h:75
ITER begin()
Definition: selection.h:74
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 SetBitmap(const wxBitmapBundle &aBmp)
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.
Definition: common.cpp:343
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
Definition: common.cpp:59
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:195
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
#define _(s)
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)
Definition: map_helpers.h:34
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.
Definition: eda_units.cpp:576
SETTINGS_MANAGER * GetSettingsManager()
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1059
see class PGM_BASE
@ LAST_PATH_STEP
Definition: project_file.h:51
std::vector< FAB_LAYER_COLOR > dummy
constexpr double IUTomm(int iu) const
Definition: base_units.h:86
constexpr int mmToIU(double mm) const
Definition: base_units.h:88
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().
Definition: wx_filename.h:39