diff --git a/eeschema/dialogs/dialog_plot_schematic.cpp b/eeschema/dialogs/dialog_plot_schematic.cpp
index 5864ac4153..4a449c4850 100644
--- a/eeschema/dialogs/dialog_plot_schematic.cpp
+++ b/eeschema/dialogs/dialog_plot_schematic.cpp
@@ -149,7 +149,7 @@ bool DIALOG_PLOT_SCHEMATIC::TransferDataToWindow()
}
wxCommandEvent dummy;
- onColorMode( dummy );
+ onPlotFormatSelection( dummy );
return true;
}
@@ -266,6 +266,10 @@ void DIALOG_PLOT_SCHEMATIC::onPlotFormatSelection( wxCommandEvent& event )
m_plotPDFHierarchicalLinks->Enable( fmt == PLOT_FORMAT::PDF );
m_plotPDFMetadata->Enable( fmt == PLOT_FORMAT::PDF );
+ // Currently kicad-cli always exports in mm (also true in Pcbnew)
+ m_staticTextDXF->Enable( fmt == PLOT_FORMAT::DXF && m_job == nullptr );
+ m_DXF_plotUnits->Enable( fmt == PLOT_FORMAT::DXF && m_job == nullptr );
+
m_paperSizeOption->SetSelection( m_paperSizeOption->GetSelection() );
m_defaultLineWidth.Enable( fmt == PLOT_FORMAT::POST || fmt == PLOT_FORMAT::PDF || fmt == PLOT_FORMAT::SVG );
@@ -333,6 +337,9 @@ void DIALOG_PLOT_SCHEMATIC::plotSchematic( bool aPlotAll )
plotOpts.m_pageSizeSelect = m_paperSizeOption->GetSelection();
plotOpts.m_plotHopOver = m_editFrame->Schematic().Settings().m_HopOverScale > 0.0;
+ // Select the DXF file unit
+ plotOpts.m_DXF_File_Unit = m_DXF_plotUnits->GetSelection() == 0 ? DXF_UNITS::INCH : DXF_UNITS::MM;
+
schPlotter->Plot( getPlotFileFormat(), plotOpts, &renderSettings, &m_MessagesBox->Reporter() );
if( getPlotFileFormat() == PLOT_FORMAT::PDF && m_openFileAfterPlot->GetValue() )
diff --git a/eeschema/dialogs/dialog_plot_schematic_base.cpp b/eeschema/dialogs/dialog_plot_schematic_base.cpp
index bbdbf03a68..a30f9008b7 100644
--- a/eeschema/dialogs/dialog_plot_schematic_base.cpp
+++ b/eeschema/dialogs/dialog_plot_schematic_base.cpp
@@ -139,7 +139,28 @@ DIALOG_PLOT_SCHEMATIC_BASE::DIALOG_PLOT_SCHEMATIC_BASE( wxWindow* parent, wxWind
sbSizer4->Add( m_plotPDFMetadata, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
- bOptionsRight->Add( sbSizer4, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
+ bOptionsRight->Add( sbSizer4, 0, wxEXPAND|wxALL, 5 );
+
+ m_SizerDxfOption = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("DXF Options") ), wxVERTICAL );
+
+ wxBoxSizer* bSizerDxf;
+ bSizerDxf = new wxBoxSizer( wxHORIZONTAL );
+
+ m_staticTextDXF = new wxStaticText( m_SizerDxfOption->GetStaticBox(), wxID_ANY, _("Export units"), wxDefaultPosition, wxDefaultSize, 0 );
+ m_staticTextDXF->Wrap( -1 );
+ bSizerDxf->Add( m_staticTextDXF, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
+
+ wxString m_DXF_plotUnitsChoices[] = { _("Inches"), _("Millimeters") };
+ int m_DXF_plotUnitsNChoices = sizeof( m_DXF_plotUnitsChoices ) / sizeof( wxString );
+ m_DXF_plotUnits = new wxChoice( m_SizerDxfOption->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_DXF_plotUnitsNChoices, m_DXF_plotUnitsChoices, 0 );
+ m_DXF_plotUnits->SetSelection( 0 );
+ bSizerDxf->Add( m_DXF_plotUnits, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
+
+
+ m_SizerDxfOption->Add( bSizerDxf, 1, wxEXPAND, 5 );
+
+
+ bOptionsRight->Add( m_SizerDxfOption, 1, wxEXPAND|wxTOP|wxBOTTOM, 5 );
m_otherOptions = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Other Options") ), wxVERTICAL );
diff --git a/eeschema/dialogs/dialog_plot_schematic_base.fbp b/eeschema/dialogs/dialog_plot_schematic_base.fbp
index 60208f2c3d..732780b768 100644
--- a/eeschema/dialogs/dialog_plot_schematic_base.fbp
+++ b/eeschema/dialogs/dialog_plot_schematic_base.fbp
@@ -1131,7 +1131,7 @@
none
+
+ 5
+ wxEXPAND|wxTOP|wxBOTTOM
+ 1
+
+ wxID_ANY
+ DXF Options
+
+ m_SizerDxfOption
+ wxVERTICAL
+ 1
+ protected
+
+ 5
+ wxEXPAND
+ 1
+
+
+ bSizerDxf
+ wxHORIZONTAL
+ none
+
+ 5
+ wxALL|wxALIGN_CENTER_VERTICAL
+ 0
+
+ 1
+ 1
+ 1
+ 1
+ 0
+
+ 0
+ 0
+
+
+
+ 1
+ 0
+ 1
+
+ 1
+ 0
+ Dock
+ 0
+ Left
+ 0
+ 1
+
+ 1
+
+ 0
+ 0
+ wxID_ANY
+ Export units
+ 0
+
+ 0
+
+
+ 0
+
+ 1
+ m_staticTextDXF
+ 1
+
+
+ protected
+ 1
+
+ Resizable
+ 1
+
+
+ ; ; forward_declare
+ 0
+
+
+
+
+ -1
+
+
+
+ 5
+ wxALL|wxALIGN_CENTER_VERTICAL
+ 0
+
+ 1
+ 1
+ 1
+ 1
+ 0
+
+ 0
+ 0
+
+
+
+ 1
+ 0
+ "Inches" "Millimeters"
+ 1
+
+ 1
+ 0
+ Dock
+ 0
+ Left
+ 0
+ 1
+
+ 1
+
+ 0
+ 0
+ wxID_ANY
+
+ 0
+
+
+ 0
+
+ 1
+ m_DXF_plotUnits
+ 1
+
+
+ protected
+ 1
+
+ Resizable
+ 0
+ 1
+
+
+ ; ; forward_declare
+ 0
+
+
+ wxFILTER_NONE
+ wxDefaultValidator
+
+
+
+
+
+
+
+
+
+
5
wxEXPAND|wxTOP|wxRIGHT|wxLEFT
diff --git a/eeschema/dialogs/dialog_plot_schematic_base.h b/eeschema/dialogs/dialog_plot_schematic_base.h
index fe69169739..a671036ce1 100644
--- a/eeschema/dialogs/dialog_plot_schematic_base.h
+++ b/eeschema/dialogs/dialog_plot_schematic_base.h
@@ -63,6 +63,9 @@ class DIALOG_PLOT_SCHEMATIC_BASE : public DIALOG_SHIM
wxCheckBox* m_plotPDFPropertyPopups;
wxCheckBox* m_plotPDFHierarchicalLinks;
wxCheckBox* m_plotPDFMetadata;
+ wxStaticBoxSizer* m_SizerDxfOption;
+ wxStaticText* m_staticTextDXF;
+ wxChoice* m_DXF_plotUnits;
wxStaticBoxSizer* m_otherOptions;
wxCheckBox* m_openFileAfterPlot;
WX_HTML_REPORT_PANEL* m_MessagesBox;
diff --git a/eeschema/eeschema_jobs_handler.cpp b/eeschema/eeschema_jobs_handler.cpp
index 97eabab8d6..d6aff3fd9d 100644
--- a/eeschema/eeschema_jobs_handler.cpp
+++ b/eeschema/eeschema_jobs_handler.cpp
@@ -343,6 +343,9 @@ int EESCHEMA_JOBS_HANDLER::JobExportPlot( JOB* aJob )
plotOpts.m_useBackgroundColor = aPlotJob->m_useBackgroundColor;
plotOpts.m_plotHopOver = aPlotJob->m_show_hop_over;
+ // Always export dxf in mm by kicad-cli (similar to Pcbnew)
+ plotOpts.m_DXF_File_Unit = DXF_UNITS::MM;
+
schPlotter->Plot( format, plotOpts, renderSettings.get(), m_reporter );
if( m_reporter->HasMessageOfSeverity( RPT_SEVERITY_ERROR ) )
diff --git a/eeschema/sch_plotter.cpp b/eeschema/sch_plotter.cpp
index 759acb361c..3e2cecc4cb 100644
--- a/eeschema/sch_plotter.cpp
+++ b/eeschema/sch_plotter.cpp
@@ -776,6 +776,8 @@ bool SCH_PLOTTER::plotOneSheetDXF( const wxString& aFileName, SCH_SCREEN* aScree
const PAGE_INFO& pageInfo = aScreen->GetPageSettings();
DXF_PLOTTER* plotter = new DXF_PLOTTER();
+ plotter->SetUnits( aPlotOpts.m_DXF_File_Unit );
+
plotter->SetRenderSettings( aRenderSettings );
plotter->SetPageSettings( pageInfo );
plotter->SetColorMode( !aPlotOpts.m_blackAndWhite );
diff --git a/eeschema/sch_plotter.h b/eeschema/sch_plotter.h
index bf05073334..43d62982e0 100644
--- a/eeschema/sch_plotter.h
+++ b/eeschema/sch_plotter.h
@@ -68,6 +68,8 @@ struct SCH_PLOT_OPTS
wxString m_outputDirectory;
wxString m_outputFile;
+ // has meaning only with DXF plotter: set DXF units in DXF file
+ DXF_UNITS m_DXF_File_Unit;
SCH_PLOT_OPTS() :
m_plotAll( true ),
@@ -81,7 +83,8 @@ struct SCH_PLOT_OPTS
m_PDFMetadata( false ),
m_theme(),
m_outputDirectory(),
- m_outputFile()
+ m_outputFile(),
+ m_DXF_File_Unit( DXF_UNITS::INCH )
{
}