Ensure that layer names are unique when importing

Altium allows duplicate layer names but KiCad prefers to have unique
names for each layer.  This enforces a unique name for each layer when
importing

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15583
This commit is contained in:
Seth Hillbrand 2023-09-27 18:04:24 -07:00
parent 06428e0161
commit c772d116b2
2 changed files with 9 additions and 1 deletions

View File

@ -274,6 +274,13 @@ ABOARD6::ABOARD6( ALTIUM_PARSER& aReader )
ABOARD6_LAYER_STACKUP l; ABOARD6_LAYER_STACKUP l;
l.name = ALTIUM_PARSER::ReadString( props, layername, wxT( "" ) ); l.name = ALTIUM_PARSER::ReadString( props, layername, wxT( "" ) );
wxString originalName = l.name;
int ii = 2;
// Ensure that layer names are unique in KiCad
while( !layerNames.insert( l.name ).second )
l.name = wxString::Format( wxT( "%s %d" ), originalName, ii++ );
l.nextId = ALTIUM_PARSER::ReadInt( props, layeri + wxT( "NEXT" ), 0 ); l.nextId = ALTIUM_PARSER::ReadInt( props, layeri + wxT( "NEXT" ), 0 );
l.prevId = ALTIUM_PARSER::ReadInt( props, layeri + wxT( "PREV" ), 0 ); l.prevId = ALTIUM_PARSER::ReadInt( props, layeri + wxT( "PREV" ), 0 );
l.copperthick = ALTIUM_PARSER::ReadKicadUnit( props, layeri + wxT( "COPTHICK" ), wxT( "1.4mil" ) ); l.copperthick = ALTIUM_PARSER::ReadKicadUnit( props, layeri + wxT( "COPTHICK" ), wxT( "1.4mil" ) );

View File

@ -377,6 +377,7 @@ struct ABOARD6
int layercount; int layercount;
std::vector<ABOARD6_LAYER_STACKUP> stackup; std::vector<ABOARD6_LAYER_STACKUP> stackup;
std::set<wxString> layerNames;
std::vector<ALTIUM_VERTICE> board_vertices; std::vector<ALTIUM_VERTICE> board_vertices;