94 bool doPlaceSymbol, wxString& aError )
102 aError =
_(
"Unable to load schematic settings." );
113 const bool strictLibraryTables =
m_frame !=
nullptr;
116 bool didImportSymbol =
false;
117 wxString toPlaceNickname;
118 wxString toPlaceSymbolName;
124 std::vector<size_t> footprintIndexes;
125 std::vector<size_t> otherIndexes;
126 std::vector<size_t> symbolIndexes;
128 for(
size_t i = 0; i < aManifest.
assets.size(); ++i )
130 const wxString& type = aManifest.
assets[i].asset_type;
132 if( type == wxS(
"footprint" ) )
133 footprintIndexes.push_back( i );
134 else if( type == wxS(
"symbol" ) )
135 symbolIndexes.push_back( i );
137 otherIndexes.push_back( i );
140 std::vector<LIB_ID> footprintLinks;
145 if( !
downloader().DownloadAndVerify( aProvider, aManifest.
assets[i], remainingBudget, fetched,
151 remainingBudget -= aManifest.
assets[i].size_bytes;
156 for(
size_t footprintIdx : footprintIndexes )
161 if( !downloadAsset( footprintIdx, fetched ) )
164 wxFileName fpRoot = baseDir;
165 fpRoot.AppendDir( wxS(
"footprints" ) );
173 wxFileName libDir = fpRoot;
174 libDir.AppendDir( nickname + wxS(
".pretty" ) );
178 wxFileName outFile( libDir );
179 outFile.SetFullName( fileName );
184 if( strictLibraryTables )
196 footprintLinks.push_back( fpLibId );
200 for(
size_t otherIdx : otherIndexes )
205 if( !downloadAsset( otherIdx, fetched ) )
210 wxFileName modelDir = baseDir;
211 modelDir.AppendDir( prefix + wxS(
"_3d" ) );
215 prefix + wxS(
"_model" ) );
217 wxFileName outFile( modelDir );
218 outFile.SetFullName( fileName );
225 wxFileName spiceDir = baseDir;
226 spiceDir.AppendDir( prefix + wxS(
"_spice" ) );
230 prefix + wxS(
"_model.cir" ) );
232 if( !fileName.Lower().EndsWith( wxS(
".cir" ) ) )
233 fileName += wxS(
".cir" );
235 wxFileName outFile( spiceDir );
236 outFile.SetFullName( fileName );
244 for(
size_t symbolIdx : symbolIndexes )
249 if( !downloadAsset( symbolIdx, fetched ) )
252 wxFileName symbolDir = baseDir;
253 symbolDir.AppendDir( wxS(
"symbols" ) );
258 wxS(
"symbols" ),
true );
260 const wxString nickname = prefix + wxS(
"_" ) + libraryName;
262 wxFileName outFile( symbolDir );
263 outFile.SetFullName( nickname + wxS(
".kicad_sym" ) );
265 if( strictLibraryTables && symbolName.IsEmpty() )
267 aError =
_(
"No symbol asset specified." );
271 if( !validateSymbolPayload( fetched.
payload, symbolName, aError ) )
280 didImportSymbol =
true;
282 loadedSymbol->SetName( symbolName );
286 loadedSymbol->SetLibId( savedId );
291 if( !symbolDir.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
293 aError = wxString::Format(
_(
"Unable to create directory '%s'." ), symbolDir.GetPath() );
297 if( strictLibraryTables )
306 aError =
_(
"Unable to access the symbol library manager." );
334 aError =
_(
"Unable to access the KiCad symbol plugin." );
338 plugin->SaveSymbol( outFile.GetFullPath(), std::move( loadedSymbol ) );
342 aError = wxString::Format(
_(
"Unable to save the downloaded symbol: %s" ), e.
What() );
350 toPlaceNickname = nickname;
351 toPlaceSymbolName = symbolName;
356 if( !didImportSymbol )
358 aError =
_(
"No symbol asset was available to place." );