Replace WRL files with STEP equivalent

- Use simple filename matching
- If a STEP file is found, use that instead
- Similar behaviour to the infamous StepUp tool

Fixes lp:1710796

https://bugs.launchpad.net/kicad/+bug/1710796
This commit is contained in:
Oliver 2017-11-04 23:44:13 +11:00 committed by Wayne Stambaugh
parent 9df4ae65ea
commit 30455092c8
1 changed files with 56 additions and 1 deletions

View File

@ -148,7 +148,8 @@ enum FormatType
FMT_STEP = 1,
FMT_IGES = 2,
FMT_EMN = 3,
FMT_IDF = 4
FMT_IDF = 4,
FMT_WRL = 5, // .wrl files are replaced with MCAD equivalent
};
@ -168,6 +169,9 @@ FormatType fileType( const char* aFileName )
wxString ext = lfile.GetExt();
if( ext.Lower() == "wrl" )
return FMT_WRL;
if( ext == "idf" || ext == "IDF" )
return FMT_IDF; // component outline
else if( ext == "emn" || ext == "EMN" )
@ -888,6 +892,57 @@ bool PCBMODEL::getModelLabel( const std::string aFileName, TDF_Label& aLabel )
}
break;
case FMT_WRL:
/* WRL files are preferred for internal rendering,
* due to superior material properties, etc.
* However they are not suitable for MCAD export.
*
* If a .wrl file is specified, attempt to locate
* a replacement file for it.
*
* If a valid replacement file is found, the label
* for THAT file will be associated with the .wrl file
*
*/
{
wxFileName wrlName( aFileName );
wxString basePath = wrlName.GetPath();
wxString baseName = wrlName.GetName();
// List of alternate files to look for
// Given in order of preference
// (Break if match is found)
wxArrayString alts;
// Step files
alts.Add( "stp" );
alts.Add( "step" );
alts.Add( "STP" );
alts.Add( "STEP" );
alts.Add( "Stp" );
alts.Add( "Step" );
//TODO - Other alternative formats?
for( auto alt : alts )
{
wxFileName altFile( basePath, baseName + "." + alt );
if( altFile.IsOk() && altFile.FileExists() )
{
std::string altFileName = altFile.GetFullPath().ToStdString();
if( getModelLabel( altFileName, aLabel ) )
{
return true;
}
}
}
}
break;
// TODO: implement IDF and EMN converters
default: