0001160: Freecad sometimes 'forgets' the ability to handle stp files
This commit is contained in:
parent
7f216323ff
commit
4b2474807b
|
@ -57,6 +57,7 @@
|
||||||
# include <TopExp_Explorer.hxx>
|
# include <TopExp_Explorer.hxx>
|
||||||
# include <TopoDS_Iterator.hxx>
|
# include <TopoDS_Iterator.hxx>
|
||||||
# include <APIHeaderSection_MakeHeader.hxx>
|
# include <APIHeaderSection_MakeHeader.hxx>
|
||||||
|
# include <OSD_Exception.hxx>
|
||||||
#if OCC_VERSION_HEX >= 0x060500
|
#if OCC_VERSION_HEX >= 0x060500
|
||||||
# include <TDataXtd_Shape.hxx>
|
# include <TDataXtd_Shape.hxx>
|
||||||
# else
|
# else
|
||||||
|
@ -74,6 +75,8 @@
|
||||||
#include <Mod/Part/Gui/ViewProvider.h>
|
#include <Mod/Part/Gui/ViewProvider.h>
|
||||||
#include <Mod/Part/App/PartFeature.h>
|
#include <Mod/Part/App/PartFeature.h>
|
||||||
#include <Mod/Part/App/ProgressIndicator.h>
|
#include <Mod/Part/App/ProgressIndicator.h>
|
||||||
|
#include <Mod/Part/App/ImportIges.h>
|
||||||
|
#include <Mod/Part/App/ImportStep.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -507,6 +510,7 @@ static PyObject * importer(PyObject *self, PyObject *args)
|
||||||
hApp->NewDocument(TCollection_ExtendedString("MDTV-CAF"), hDoc);
|
hApp->NewDocument(TCollection_ExtendedString("MDTV-CAF"), hDoc);
|
||||||
|
|
||||||
if (file.hasExtension("stp") || file.hasExtension("step")) {
|
if (file.hasExtension("stp") || file.hasExtension("step")) {
|
||||||
|
try {
|
||||||
STEPCAFControl_Reader aReader;
|
STEPCAFControl_Reader aReader;
|
||||||
aReader.SetColorMode(true);
|
aReader.SetColorMode(true);
|
||||||
aReader.SetNameMode(true);
|
aReader.SetNameMode(true);
|
||||||
|
@ -523,7 +527,17 @@ static PyObject * importer(PyObject *self, PyObject *args)
|
||||||
aReader.Transfer(hDoc);
|
aReader.Transfer(hDoc);
|
||||||
pi->EndScope();
|
pi->EndScope();
|
||||||
}
|
}
|
||||||
|
catch (OSD_Exception) {
|
||||||
|
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||||
|
Base::Console().Error("%s\n", e->GetMessageString());
|
||||||
|
Base::Console().Message("Try to load STEP file without colors...\n");
|
||||||
|
|
||||||
|
Part::ImportStepParts(pcDoc,Name);
|
||||||
|
pcDoc->recompute();
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (file.hasExtension("igs") || file.hasExtension("iges")) {
|
else if (file.hasExtension("igs") || file.hasExtension("iges")) {
|
||||||
|
try {
|
||||||
IGESControl_Controller::Init();
|
IGESControl_Controller::Init();
|
||||||
Interface_Static::SetIVal("read.surfacecurve.mode",3);
|
Interface_Static::SetIVal("read.surfacecurve.mode",3);
|
||||||
IGESCAFControl_Reader aReader;
|
IGESCAFControl_Reader aReader;
|
||||||
|
@ -542,6 +556,15 @@ static PyObject * importer(PyObject *self, PyObject *args)
|
||||||
aReader.Transfer(hDoc);
|
aReader.Transfer(hDoc);
|
||||||
pi->EndScope();
|
pi->EndScope();
|
||||||
}
|
}
|
||||||
|
catch (OSD_Exception) {
|
||||||
|
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||||
|
Base::Console().Error("%s\n", e->GetMessageString());
|
||||||
|
Base::Console().Message("Try to load IGES file without colors...\n");
|
||||||
|
|
||||||
|
Part::ImportIgesParts(pcDoc,Name);
|
||||||
|
pcDoc->recompute();
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
PyErr_SetString(PyExc_Exception, "no supported file format");
|
PyErr_SetString(PyExc_Exception, "no supported file format");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -50,6 +50,8 @@ if(MSVC)
|
||||||
set_target_properties(ImportGui PROPERTIES DEBUG_OUTPUT_NAME "ImportGui_d")
|
set_target_properties(ImportGui PROPERTIES DEBUG_OUTPUT_NAME "ImportGui_d")
|
||||||
set_target_properties(ImportGui PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Mod/Import)
|
set_target_properties(ImportGui PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Mod/Import)
|
||||||
set_target_properties(ImportGui PROPERTIES PREFIX "../")
|
set_target_properties(ImportGui PROPERTIES PREFIX "../")
|
||||||
|
# Set special compiler flag to convert a SIGSEV into an exception
|
||||||
|
set_target_properties(ImportGui PROPERTIES COMPILE_FLAGS "/EHa")
|
||||||
elseif(MINGW)
|
elseif(MINGW)
|
||||||
set_target_properties(ImportGui PROPERTIES SUFFIX ".pyd")
|
set_target_properties(ImportGui PROPERTIES SUFFIX ".pyd")
|
||||||
set_target_properties(ImportGui PROPERTIES DEBUG_OUTPUT_NAME "ImportGui_d")
|
set_target_properties(ImportGui PROPERTIES DEBUG_OUTPUT_NAME "ImportGui_d")
|
||||||
|
|
|
@ -93,16 +93,6 @@ void PartExport initPart()
|
||||||
str << OCC_VERSION_MAJOR << "." << OCC_VERSION_MINOR << "." << OCC_VERSION_MAINTENANCE;
|
str << OCC_VERSION_MAJOR << "." << OCC_VERSION_MINOR << "." << OCC_VERSION_MAINTENANCE;
|
||||||
App::Application::Config()["OCC_VERSION"] = str.str();
|
App::Application::Config()["OCC_VERSION"] = str.str();
|
||||||
|
|
||||||
// see Init.py
|
|
||||||
#if defined (_OCC64)
|
|
||||||
#if OCC_VERSION_HEX < 0x060503
|
|
||||||
App::GetApplication().addImportType("STEP (*.step *.stp)","Part");
|
|
||||||
App::GetApplication().addExportType("STEP (*.step *.stp)","Part");
|
|
||||||
#else
|
|
||||||
App::GetApplication().addImportType("STEP with colors (*.step *.stp)","ImportGui");
|
|
||||||
App::GetApplication().addExportType("STEP with colors (*.step *.stp)","ImportGui");
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
// This is highly experimental and we should keep an eye on it
|
// This is highly experimental and we should keep an eye on it
|
||||||
// if we have mysterious crashes
|
// if we have mysterious crashes
|
||||||
// The argument must be 'Standard_False' to avoid FPE caused by
|
// The argument must be 'Standard_False' to avoid FPE caused by
|
||||||
|
|
|
@ -33,7 +33,7 @@ class Document;
|
||||||
namespace Part
|
namespace Part
|
||||||
{
|
{
|
||||||
|
|
||||||
int ImportIgesParts(App::Document *pcDoc, const char* Name);
|
PartExport int ImportIgesParts(App::Document *pcDoc, const char* Name);
|
||||||
|
|
||||||
} //namespace Part
|
} //namespace Part
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace Part
|
||||||
|
|
||||||
/** The part shape property
|
/** The part shape property
|
||||||
*/
|
*/
|
||||||
int ImportStepParts(App::Document *pcDoc, const char* Name);
|
PartExport int ImportStepParts(App::Document *pcDoc, const char* Name);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,14 +49,5 @@ FreeCAD.addImportType("BREP format (*.brep *.brp)","Part")
|
||||||
FreeCAD.addExportType("BREP format (*.brep *.brp)","Part")
|
FreeCAD.addExportType("BREP format (*.brep *.brp)","Part")
|
||||||
FreeCAD.addImportType("IGES format (*.iges *.igs)","Part")
|
FreeCAD.addImportType("IGES format (*.iges *.igs)","Part")
|
||||||
FreeCAD.addExportType("IGES format (*.iges *.igs)","Part")
|
FreeCAD.addExportType("IGES format (*.iges *.igs)","Part")
|
||||||
|
FreeCAD.addImportType("STEP with colors (*.step *.stp)","ImportGui")
|
||||||
# There is a bug in OCC 6.5.0 64-bit and older which leads to a crash
|
FreeCAD.addExportType("STEP with colors (*.step *.stp)","ImportGui")
|
||||||
# The registration of the STEP filetype for 64-bit is handled in initPart()
|
|
||||||
import platform
|
|
||||||
if platform.architecture()[0]=='32bit':
|
|
||||||
FreeCAD.addImportType("STEP with colors (*.step *.stp)","ImportGui")
|
|
||||||
FreeCAD.addExportType("STEP with colors (*.step *.stp)","ImportGui")
|
|
||||||
#else:
|
|
||||||
# FreeCAD.addImportType("STEP (*.step *.stp)","Part")
|
|
||||||
# FreeCAD.addExportType("STEP (*.step *.stp)","Part")
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user