Fix footprint relative path resolution for idf/vrml export

This commit is contained in:
Marek Roszko 2022-09-25 23:40:25 -04:00
parent 707a598e5d
commit cfa26fb706
2 changed files with 29 additions and 2 deletions

View File

@ -30,6 +30,7 @@
#include <board.h>
#include <board_design_settings.h>
#include <footprint.h>
#include <fp_lib_table.h>
#include <fp_shape.h>
#include <idf_parser.h>
#include <pad.h>
@ -275,6 +276,18 @@ static void idf_export_footprint( BOARD* aPcb, FOOTPRINT* aFootprint, IDF3_BOARD
// Reference Designator
std::string crefdes = TO_UTF8( aFootprint->Reference().GetShownText() );
wxString libraryName = aFootprint->GetFPID().GetLibNickname();
wxString footprintBasePath = wxEmptyString;
if( aPcb->GetProject() )
{
const FP_LIB_TABLE_ROW* fpRow =
aPcb->GetProject()->PcbFootprintLibs()->FindRow( libraryName, false );
if( fpRow )
footprintBasePath = fpRow->GetFullURI( true );
}
if( crefdes.empty() || !crefdes.compare( "~" ) )
{
std::string cvalue = TO_UTF8( aFootprint->Value().GetShownText() );
@ -411,7 +424,7 @@ static void idf_export_footprint( BOARD* aPcb, FOOTPRINT* aFootprint, IDF3_BOARD
continue;
}
idfFile.Assign( resolver->ResolvePath( sM->m_Filename, wxEmptyString ) );
idfFile.Assign( resolver->ResolvePath( sM->m_Filename, footprintBasePath ) );
idfExt = idfFile.GetExt();
if( idfExt.Cmp( wxT( "idf" ) ) && idfExt.Cmp( wxT( "IDF" ) ) )

View File

@ -33,6 +33,7 @@
#include "3d_cache/3d_info.h"
#include "board.h"
#include "board_design_settings.h"
#include <fp_lib_table.h>
#include "fp_shape.h"
#include "footprint.h"
#include "pad.h"
@ -993,6 +994,19 @@ void EXPORTER_PCB_VRML::ExportVrmlFootprint( FOOTPRINT* aFootprint, std::ostream
// file contains only the filename of 3D shapes to add to the full vrml scene
wxCHECK( aFootprint, /* void */ );
wxString libraryName = aFootprint->GetFPID().GetLibNickname();
wxString footprintBasePath = wxEmptyString;
if( m_board->GetProject() )
{
const FP_LIB_TABLE_ROW* fpRow =
m_board->GetProject()->PcbFootprintLibs()->FindRow( libraryName, false );
if( fpRow )
footprintBasePath = fpRow->GetFullURI( true );
}
// Export pad holes
for( PAD* pad : aFootprint->Pads() )
ExportVrmlPadHole( pad );
@ -1013,7 +1027,7 @@ void EXPORTER_PCB_VRML::ExportVrmlFootprint( FOOTPRINT* aFootprint, std::ostream
continue;
}
SGNODE* mod3d = (SGNODE*) m_Cache3Dmodels->Load( sM->m_Filename, wxEmptyString );
SGNODE* mod3d = (SGNODE*) m_Cache3Dmodels->Load( sM->m_Filename, footprintBasePath );
if( nullptr == mod3d )
{