Added code to map footprint lib nicknames when exporting.
This is particularly useful when you import (for instance) an Altium board and then save the footprints out to a new library. Fixes https://gitlab.com/kicad/code/kicad/issues/6345
This commit is contained in:
parent
3efa391eb2
commit
1fd555ce0e
|
@ -686,6 +686,9 @@ void PCB_EDIT_FRAME::ExportFootprintsToLibrary( bool aStoreInNewLib, const wxStr
|
|||
if( !nickname ) // Aborted
|
||||
return;
|
||||
|
||||
bool map = IsOK( this, wxString::Format( _( "Update footprints on board to refer to %s?" ),
|
||||
nickname ) );
|
||||
|
||||
prj.SetRString( PROJECT::PCB_LIB_NICKNAME, nickname );
|
||||
|
||||
for( FOOTPRINT* footprint : GetBoard()->Footprints() )
|
||||
|
@ -708,6 +711,13 @@ void PCB_EDIT_FRAME::ExportFootprintsToLibrary( bool aStoreInNewLib, const wxStr
|
|||
{
|
||||
DisplayError( this, ioe.What() );
|
||||
}
|
||||
|
||||
if( map )
|
||||
{
|
||||
LIB_ID id = footprint->GetFPID();
|
||||
id.SetLibNickname( nickname );
|
||||
footprint->SetFPID( id );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -722,6 +732,17 @@ void PCB_EDIT_FRAME::ExportFootprintsToLibrary( bool aStoreInNewLib, const wxStr
|
|||
if( aLibPath )
|
||||
*aLibPath = libPath;
|
||||
|
||||
wxString libNickname;
|
||||
bool map = IsOK( this, _( "Update footprints on board to refer to new library?" ) );
|
||||
|
||||
if( map )
|
||||
{
|
||||
const LIB_TABLE_ROW* row = Prj().PcbFootprintLibs()->FindRowByURI( libPath );
|
||||
|
||||
if( row )
|
||||
libNickname = row->GetNickName();
|
||||
}
|
||||
|
||||
IO_MGR::PCB_FILE_T piType = IO_MGR::KICAD_SEXP;
|
||||
PLUGIN::RELEASER pi( IO_MGR::PluginFind( piType ) );
|
||||
|
||||
|
@ -743,6 +764,13 @@ void PCB_EDIT_FRAME::ExportFootprintsToLibrary( bool aStoreInNewLib, const wxStr
|
|||
{
|
||||
DisplayError( this, ioe.What() );
|
||||
}
|
||||
|
||||
if( map )
|
||||
{
|
||||
LIB_ID id = footprint->GetFPID();
|
||||
id.SetLibNickname( libNickname );
|
||||
footprint->SetFPID( id );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue