46 if( aUseCurrentSheetFilename )
51 fn.SetName( fn.GetName() +
"-cache" );
59 schematic.UpdateSymbolLinks();
75 archLib->EnableBuffering();
88 auto component = static_cast<SCH_COMPONENT*>( aItem );
92 if( archLib->FindPart( component->GetLibId() ) )
95 part =
GetLibPart( component->GetLibId(), true );
100 tmp.Printf(
_(
"Failed to add symbol \"%s\" to library file \"%s\"." ),
101 component->GetLibId().GetUniStringLibItemName(), aFileName );
108 tmp =
_(
"Unexpected exception occurred." );
113 std::unique_ptr<LIB_PART> flattenedPart = part->
Flatten();
116 flattenedPart->SetName( component->GetLibId().GetUniStringLibId() );
119 archLib->AddPart( flattenedPart.get() );
123 tmp.Printf(
_(
"Symbol %s not found in any library or cache." ),
124 component->GetLibId().GetUniStringLibId() );
127 if( !tmp.empty() && !errorMsg.Contains( component->GetLibId().GetUniStringLibId() ) )
129 if( errorMsg.empty() )
132 errorMsg +=
"\n" + tmp;
137 if( !errorMsg.empty() )
139 tmp.Printf(
_(
"Errors occurred creating symbol library %s." ), aFileName );
143 archLib->EnableBuffering(
false );
147 archLib->Save(
false );
151 errorMsg.Printf(
_(
"Failed to save symbol library file \"%s\"" ), aFileName );
155 catch( std::exception& error )
157 errorMsg.Printf(
_(
"Failed to save symbol library file \"%s\"" ), aFileName );
const wxString & GetFileName() const
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
const std::string LegacySymbolLibFileExtension
LIB_PART * GetLibPart(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
virtual const wxString What() const
A composite of Problem() and Where()
SCHEMATIC & Schematic() const
Define a library symbol object.
Definition of file extensions used in Kicad.
bool CreateArchiveLibraryCacheFile(bool aUseCurrentSheetFilename=false)
Create a symbol library file with the name of the root document plus the '-cache' suffix,...
std::unique_ptr< LIB_PART > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition for part library class.
SCH_SCREEN * RootScreen() const
Helper to retreive the screen of the root sheet.
bool CreateArchiveLibrary(const wxString &aFileName)
Create a library aFileName that contains all components used in the current schematic.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.