Add $INSUNITS header variable to DXF export
The DXF exporter was missing the $INSUNITS header variable, which tells
CAD software what physical units the drawing coordinates represent. Without
it, other programs have no reliable way to determine the coordinate scale.
Add $INSUNITS to the HEADER section alongside the existing $MEASUREMENT
variable. When exporting in millimeters, $INSUNITS is set to 4; when
exporting in inches, it is set to 1.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/23181
(cherry picked from commit c0a6a139cf)
This commit is contained in:
@@ -141,12 +141,14 @@ void DXF_PLOTTER::SetUnits( DXF_UNITS aUnit )
|
||||
case DXF_UNITS::MM:
|
||||
m_unitScalingFactor = 0.00254;
|
||||
m_measurementDirective = 1;
|
||||
m_insUnits = 4;
|
||||
break;
|
||||
|
||||
case DXF_UNITS::INCH:
|
||||
default:
|
||||
m_unitScalingFactor = 0.0001;
|
||||
m_measurementDirective = 0;
|
||||
m_insUnits = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,6 +221,10 @@ bool DXF_PLOTTER::StartPlot( const wxString& aPageNumber )
|
||||
"$MEASUREMENT\n"
|
||||
" 70\n"
|
||||
"%u\n"
|
||||
" 9\n"
|
||||
"$INSUNITS\n"
|
||||
" 70\n"
|
||||
"%u\n"
|
||||
" 0\n"
|
||||
"ENDSEC\n"
|
||||
" 0\n"
|
||||
@@ -313,7 +319,7 @@ bool DXF_PLOTTER::StartPlot( const wxString& aPageNumber )
|
||||
"-0.2\n"
|
||||
" 0\n"
|
||||
"ENDTAB\n",
|
||||
GetMeasurementDirective() );
|
||||
GetMeasurementDirective(), GetInsUnits() );
|
||||
|
||||
// Text styles table
|
||||
// Defines 4 text styles, one for each bold/italic combination
|
||||
|
||||
Reference in New Issue
Block a user