Step export: shows a report message if a 3D model is not loadable:

- When a vrml model is specified and model substitution is not allowed
- When the model substitution is allowed but the step model is not found
This commit is contained in:
jean-pierre charras 2021-07-08 17:22:33 +02:00
parent f59ee53540
commit 702c0d6f72
2 changed files with 28 additions and 4 deletions

View File

@ -617,10 +617,15 @@ bool PCBMODEL::AddComponent( const std::string& aFileName, const std::string& aR
// first retrieve a label
TDF_Label lmodel;
wxString errorMessage;
if( !getModelLabel( aFileName, aScale, lmodel, aSubstituteModels ) )
if( !getModelLabel( aFileName, aScale, lmodel, aSubstituteModels, &errorMessage ) )
{
ReportMessage( wxString::Format( "No model for filename '%s'.\n", aFileName ) );
if( errorMessage.IsEmpty() )
ReportMessage( wxString::Format( "No model for filename '%s'.\n", aFileName ) );
else
ReportMessage( errorMessage );
return false;
}
@ -978,7 +983,7 @@ bool PCBMODEL::WriteSTEP( const wxString& aFileName )
bool PCBMODEL::getModelLabel( const std::string& aFileName, TRIPLET aScale, TDF_Label& aLabel,
bool aSubstituteModels )
bool aSubstituteModels, wxString* aErrorMessage )
{
std::string model_key = aFileName + "_" + std::to_string( aScale.x )
+ "_" + std::to_string( aScale.y ) + "_" + std::to_string( aScale.z );
@ -1148,6 +1153,15 @@ bool PCBMODEL::getModelLabel( const std::string& aFileName, TRIPLET aScale, TDF_
}
}
}
return false; // No replacement model found
}
else // Substitution is not allowed
{
if( aErrorMessage )
aErrorMessage->Printf( "Cannot add a VRML model data to a Step file.\n",
aFileName );
return false;
}
break;

View File

@ -100,8 +100,18 @@ class PCBMODEL
std::list<KICADCURVE> m_curves;
std::vector<TopoDS_Shape> m_cutouts;
/**
* Load a 3D model data
* aFileName is the filename (different formats allowed) but for WRML files a model
* data can be loaded instead of the vrml data, not suitable in a step file
* @param aScale is the X,Y,Z scaling factors
* @param aLabel is the TDF_Label to store the data
* @param aSubstituteModels = true to allows data substitution, false to disallow.
* @param aErrorMessage (can be nullptr) is an error message to be displayed on error.
* @return true if successfully loaded, false on error
*/
bool getModelLabel( const std::string& aFileName, TRIPLET aScale, TDF_Label& aLabel,
bool aSubstituteModels );
bool aSubstituteModels, wxString* aErrorMessage = nullptr );
bool getModelLocation( bool aBottom, DOUBLET aPosition, double aRotation,
TRIPLET aOffset, TRIPLET aOrientation, TopLoc_Location& aLocation );