From b57d77dd0ba2a4fe89bd1af24b106d23e2387360 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 9 Jun 2023 12:42:26 +0200 Subject: [PATCH] kicad-cli, STEP export: fix incorrect unit when user origin is specifed. They are specified in mm (or inches), but must be stored in board units in code. From master branch --- kicad/cli/command_export_pcb_step.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kicad/cli/command_export_pcb_step.cpp b/kicad/cli/command_export_pcb_step.cpp index ae53d9d8d4..430c8bdd22 100644 --- a/kicad/cli/command_export_pcb_step.cpp +++ b/kicad/cli/command_export_pcb_step.cpp @@ -116,9 +116,14 @@ int CLI::EXPORT_PCB_STEP_COMMAND::doPerform( KIWAY& aKiway ) step->m_xOrigin = atof( sm.str( 1 ).c_str() ); step->m_yOrigin = atof( sm.str( 2 ).c_str() ); + // Default unit for m_xOrigin and m_yOrigin is mm. + // Convert in to board units. If the value is given in inches, it will be converted later + step->m_xOrigin = pcbIUScale.mmToIU( step->m_xOrigin ); + step->m_yOrigin = pcbIUScale.mmToIU( step->m_yOrigin ); + std::string tunit( sm[3] ); - if( tunit.size() > 0 ) // No unit accepted ( default = mm ) + if( tunit.size() > 0 ) // unit specified ( default = mm, but can be in, inch or mm ) { if( ( !sm.str( 1 ).compare( " " ) || !sm.str( 2 ).compare( " " ) ) || ( sm.size() != 4 ) )