diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index 61a1cd0e9f..f42dcfff36 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -1140,8 +1140,10 @@ void PCB_IO::format( MODULE* aModule, int aNestLevel ) const m_out->Print( aNestLevel+1, "(model %s\n", m_out->Quotew( bs3D->m_Filename ).c_str() ); - // Model offset is in mm - m_out->Print( aNestLevel+2, "(at (xyz %s %s %s))\n", + /* Write 3D model offset in mm + * 4.0.x wrote "at" which was actually in inches + */ + m_out->Print( aNestLevel+2, "(offset (xyz %s %s %s))\n", Double2Str( bs3D->m_Offset.x ).c_str(), Double2Str( bs3D->m_Offset.y ).c_str(), Double2Str( bs3D->m_Offset.z ).c_str() ); diff --git a/pcbnew/kicad_plugin.h b/pcbnew/kicad_plugin.h index 8cbd10d029..0c0792a36b 100644 --- a/pcbnew/kicad_plugin.h +++ b/pcbnew/kicad_plugin.h @@ -46,7 +46,8 @@ class NETINFO_MAPPING; //#define SEXPR_BOARD_FILE_VERSION 20170920 // long pad names and custom pad shape //#define SEXPR_BOARD_FILE_VERSION 20170922 // Keepout zones can exist on multiple layers //#define SEXPR_BOARD_FILE_VERSION 20171114 // Save 3D model offset in mm, instead of inches -#define SEXPR_BOARD_FILE_VERSION 20171125 // Locked/unlocked TEXTE_MODULE +//#define SEXPR_BOARD_FILE_VERSION 20171125 // Locked/unlocked TEXTE_MODULE +#define SEXPR_BOARD_FILE_VERSION 20171130 // 3D model offset written using "offset" parameter #define CTL_STD_LAYER_NAMES (1 << 0) ///< Use English Standard layer names #define CTL_OMIT_NETS (1 << 1) ///< Omit pads net names (useless in library) diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp index cea3766816..4d9faa8d4c 100644 --- a/pcbnew/pcb_parser.cpp +++ b/pcbnew/pcb_parser.cpp @@ -360,25 +360,30 @@ MODULE_3D_SETTINGS* PCB_PARSER::parse3DModel() Expecting( T_xyz ); /* Note: - * Prior to SEXPR_BOARD_FILE_VERSION 20171114, - * 3D model offset was read and written in inches - * - * Now, the offset is explicitly written in mm. - * If a board is read with an older version, - * the offset is converted from inches to mm + * Prior to KiCad v5, model offset was designated by "at", + * and the units were in inches. + * Now we use mm, but support reading of legacy files */ + n3D->m_Offset.x = parseDouble( "x value" ) * 25.4f; + n3D->m_Offset.y = parseDouble( "y value" ) * 25.4f; + n3D->m_Offset.z = parseDouble( "z value" ) * 25.4f; + NeedRIGHT(); + break; + + case T_offset: + NeedLEFT(); + token = NextTok(); + + if( token != T_xyz ) + Expecting( T_xyz ); + + /* + * 3D model offset is in mm + */ n3D->m_Offset.x = parseDouble( "x value" ); n3D->m_Offset.y = parseDouble( "y value" ); n3D->m_Offset.z = parseDouble( "z value" ); - - if(m_requiredVersion < 20171114L) - { - n3D->m_Offset.x *= 25.4f; - n3D->m_Offset.y *= 25.4f; - n3D->m_Offset.z *= 25.4f; - } - NeedRIGHT(); break; @@ -409,7 +414,7 @@ MODULE_3D_SETTINGS* PCB_PARSER::parse3DModel() break; default: - Expecting( "at, scale, or rotate" ); + Expecting( "at, offset, scale, or rotate" ); } NeedRIGHT();