Fix broken library symbol links when importing CADSTAR schematics.
Under certain circumstances, the library symbol links were missing the library nickname causing the schematic symbols to appear as if the library symbol was missing. Added a helper function to create the symbol library name to avoid code duplication. Fixes https://gitlab.com/kicad/code/kicad/-/issues/17143
This commit is contained in:
parent
3024a7c569
commit
7acd057c86
|
@ -56,6 +56,26 @@ const wxString PartVersionFieldName = "Part Version";
|
|||
const wxString PartAcceptanceFieldName = "Part Acceptance";
|
||||
|
||||
|
||||
wxString CADSTAR_SCH_ARCHIVE_LOADER::CreateLibName( const wxFileName& aFileName,
|
||||
const SCH_SHEET* aRootSheet )
|
||||
{
|
||||
wxString libName = aFileName.GetName();
|
||||
|
||||
if( libName.IsEmpty() && aRootSheet )
|
||||
{
|
||||
wxFileName fn( aRootSheet->GetFileName() );
|
||||
libName = fn.GetName();
|
||||
}
|
||||
|
||||
if( libName.IsEmpty() )
|
||||
libName = "noname";
|
||||
|
||||
libName = LIB_ID::FixIllegalChars( libName, true ).wx_str();
|
||||
|
||||
return libName;
|
||||
}
|
||||
|
||||
|
||||
std::vector<LIB_SYMBOL*> CADSTAR_SCH_ARCHIVE_LOADER::LoadPartsLib( const wxString& aFilename )
|
||||
{
|
||||
if( m_progressReporter )
|
||||
|
@ -2067,8 +2087,11 @@ SCH_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol( const SYMBOL& aCads
|
|||
const LIB_SYMBOL& aKiCadPart,
|
||||
EDA_ANGLE& aComponentOrientation )
|
||||
{
|
||||
wxString libName = CreateLibName( m_footprintLibName, m_rootSheet );
|
||||
|
||||
LIB_ID libId;
|
||||
libId.SetLibItemName( aKiCadPart.GetName() );
|
||||
libId.SetLibNickname( libName );
|
||||
|
||||
int unit = getKiCadUnitNumberFromGate( aCadstarSymbol.GateID );
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ public:
|
|||
m_designCenter.y = 0;
|
||||
m_reporter = aReporter;
|
||||
m_progressReporter = aProgressReporter;
|
||||
m_fileName = aFilename;
|
||||
|
||||
// Assume that the PCB footprint library name will be the same as the schematic filename
|
||||
wxFileName schFilename( Filename );
|
||||
|
@ -96,6 +97,7 @@ public:
|
|||
*/
|
||||
void Load( SCHEMATIC* aSchematic, SCH_SHEET* aRootSheet );
|
||||
|
||||
static wxString CreateLibName( const wxFileName& aFileName, const SCH_SHEET* aRootSheet );
|
||||
|
||||
private:
|
||||
typedef std::pair<BLOCK_ID, TERMINAL_ID> BLOCK_PIN_ID;
|
||||
|
@ -112,6 +114,7 @@ private:
|
|||
REPORTER* m_reporter;
|
||||
SCHEMATIC* m_schematic;
|
||||
SCH_SHEET* m_rootSheet;
|
||||
wxFileName m_fileName;
|
||||
wxString m_footprintLibName; ///< Name of the footprint library to prepend all footprints with
|
||||
|
||||
/**
|
||||
|
|
|
@ -98,19 +98,8 @@ SCH_SHEET* SCH_IO_CADSTAR_ARCHIVE::LoadSchematicFile( const wxString& aFi
|
|||
|
||||
wxCHECK_MSG( libTable, nullptr, "Could not load symbol lib table." );
|
||||
|
||||
// Lets come up with a nice library name
|
||||
wxString libName = aSchematic->Prj().GetProjectName();
|
||||
|
||||
if( libName.IsEmpty() )
|
||||
{
|
||||
wxFileName fn( rootSheet->GetFileName() );
|
||||
libName = fn.GetName();
|
||||
}
|
||||
|
||||
if( libName.IsEmpty() )
|
||||
libName = "noname";
|
||||
|
||||
libName = LIB_ID::FixIllegalChars( libName, true ).wx_str();
|
||||
wxFileName fn = aSchematic->Prj().GetProjectFullName();
|
||||
wxString libName = CADSTAR_SCH_ARCHIVE_LOADER::CreateLibName( fn, nullptr );
|
||||
|
||||
wxFileName libFileName( aSchematic->Prj().GetProjectPath(), libName,
|
||||
FILEEXT::KiCadSymbolLibFileExtension );
|
||||
|
|
Loading…
Reference in New Issue