From a89102fdfcf0ea7b49879f360ed154d73ac0c6c0 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Fri, 25 Nov 2022 19:10:27 -0500 Subject: [PATCH] Fix Altium schematic import library symbol bug. --- eeschema/sch_plugins/altium/sch_altium_plugin.cpp | 13 +++++++++++-- eeschema/sch_sheet.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp index d9442174f1..167e2fe2ed 100644 --- a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp +++ b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp @@ -373,7 +373,7 @@ void SCH_ALTIUM_PLUGIN::ParseAltiumSch( const wxString& aFileName ) { sheet->SetScreen( new SCH_SCREEN( m_schematic ) ); SCH_SCREEN* screen = sheet->GetScreen(); - + sheet->SetName( loadAltiumFileName.GetName() ); wxCHECK2( screen, continue ); m_sheetPath.push_back( sheet ); @@ -793,8 +793,17 @@ void SCH_ALTIUM_PLUGIN::ParseComponent( int aIndex, auto pair = m_altiumComponents.insert( { aIndex, ASCH_SYMBOL( aProperties ) } ); const ASCH_SYMBOL& elem = pair.first->second; + SCH_SHEET* currentSheet = m_sheetPath.Last(); + wxCHECK( currentSheet, /* void */ ); + + wxString sheetName = currentSheet->GetName(); + + if( sheetName.IsEmpty() ) + sheetName = wxT( "root" ); + // TODO: this is a hack until we correctly apply all transformations to every element - wxString name = wxString::Format( "%d%s_%s", + wxString name = wxString::Format( "%s_%d%s_%s", + sheetName, elem.orientation, elem.isMirrored ? "_mirrored" : "", elem.libreference ); diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index ee17086cc2..74174f2a15 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -99,6 +99,7 @@ public: void SetFields( const std::vector& aFields ); wxString GetName() const { return m_fields[ SHEETNAME ].GetText(); } + void SetName( const wxString& aName ) { m_fields[ SHEETNAME ].SetText( aName ); } SCH_SCREEN* GetScreen() const { return m_screen; }