From f403295ca73d39e482a978cc8991a96813d2087f Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 29 Sep 2012 15:50:17 +0200 Subject: [PATCH] 0000832: Original color STEP model lost in import --- src/Mod/Import/Gui/AppImportGuiPy.cpp | 21 ++++++++++++++++----- src/Mod/Import/Init.py | 2 +- src/Mod/Part/App/ImportStep.cpp | 2 +- src/Mod/Part/Gui/Command.cpp | 16 ++++------------ src/Mod/Part/Init.py | 10 ++++++++-- 5 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/Mod/Import/Gui/AppImportGuiPy.cpp b/src/Mod/Import/Gui/AppImportGuiPy.cpp index d98a299d3..be5a70701 100644 --- a/src/Mod/Import/Gui/AppImportGuiPy.cpp +++ b/src/Mod/Import/Gui/AppImportGuiPy.cpp @@ -480,20 +480,24 @@ private: }; /* module functions */ + static PyObject * importer(PyObject *self, PyObject *args) { - const char* Name; - const char* DocName; - if (!PyArg_ParseTuple(args, "ss",&Name,&DocName)) + char* Name; + char* DocName=0; + if (!PyArg_ParseTuple(args, "s|s",&Name,&DocName)) return 0; PY_TRY { //Base::Console().Log("Insert in Part with %s",Name); Base::FileInfo file(Name); - App::Document *pcDoc = App::GetApplication().getDocument(DocName); + App::Document *pcDoc = 0; + if (DocName) { + pcDoc = App::GetApplication().getDocument(DocName); + } if (!pcDoc) { - pcDoc = App::GetApplication().newDocument(DocName); + pcDoc = App::GetApplication().newDocument("Unnamed"); } Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication(); @@ -561,6 +565,11 @@ static PyObject * importer(PyObject *self, PyObject *args) Py_Return; } +static PyObject * open(PyObject *self, PyObject *args) +{ + return importer(self, args); +} + static PyObject * exporter(PyObject *self, PyObject *args) { PyObject* object; @@ -946,6 +955,8 @@ static PyObject * ocaf(PyObject *self, PyObject *args) /* registration table */ struct PyMethodDef ImportGui_Import_methods[] = { + {"open" ,open ,METH_VARARGS, + "open(string) -- Open the file and create a new document."}, {"insert" ,importer ,METH_VARARGS, "insert(string,string) -- Insert the file into the given document."}, {"export" ,exporter ,METH_VARARGS, diff --git a/src/Mod/Import/Init.py b/src/Mod/Import/Init.py index 0484cbbb1..889f95b6a 100644 --- a/src/Mod/Import/Init.py +++ b/src/Mod/Import/Init.py @@ -29,5 +29,5 @@ # Append the open handler #FreeCAD.addImportType("STEP 214 (*.step *.stp)","ImportGui") -FreeCAD.addExportType("STEP 214 (*.step *.stp)","ImportGui") +#FreeCAD.addExportType("STEP 214 (*.step *.stp)","ImportGui") #FreeCAD.addExportType("IGES files (*.iges *.igs)","ImportGui") diff --git a/src/Mod/Part/App/ImportStep.cpp b/src/Mod/Part/App/ImportStep.cpp index fa05530d6..3c48532fa 100644 --- a/src/Mod/Part/App/ImportStep.cpp +++ b/src/Mod/Part/App/ImportStep.cpp @@ -125,7 +125,7 @@ int Part::ImportStepParts(App::Document *pcDoc, const char* Name) //Handle_XSControl_TransferReader tr = ws->TransferReader(); std::map hash_col; - ReadColors(aReader.WS(), hash_col); + //ReadColors(aReader.WS(), hash_col); //ReadNames(aReader.WS()); for (Standard_Integer i=1; i<=nbs; i++) { diff --git a/src/Mod/Part/Gui/Command.cpp b/src/Mod/Part/Gui/Command.cpp index 11164ce67..85563a530 100644 --- a/src/Mod/Part/Gui/Command.cpp +++ b/src/Mod/Part/Gui/Command.cpp @@ -446,11 +446,9 @@ CmdPartImport::CmdPartImport() void CmdPartImport::activated(int iMsg) { QStringList filter; - filter << QObject::tr("All CAD Files (*.stp *.step *.igs *.iges *.brp *.brep)"); - filter << QObject::tr("STEP (*.stp *.step)"); + filter << QObject::tr("STEP AP203 (*.stp *.step)"); filter << QObject::tr("IGES (*.igs *.iges)"); filter << QObject::tr("BREP (*.brp *.brep)"); - filter << QObject::tr("All Files (*.*)"); QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;"))); if (!fn.isEmpty()) { @@ -459,9 +457,7 @@ void CmdPartImport::activated(int iMsg) if (!pDoc) return; // no document openCommand("Import Part"); QString ext = QFileInfo(fn).suffix().toLower(); - if (ext == QLatin1String("step") || - ext == QLatin1String("stp") || - ext == QLatin1String("iges") || + if (ext == QLatin1String("iges") || ext == QLatin1String("igs")) { doCommand(Doc, "import ImportGui"); doCommand(Doc, "ImportGui.insert(\"%s\",\"%s\")", (const char*)fn.toUtf8(), pDoc->getName()); @@ -507,20 +503,16 @@ CmdPartExport::CmdPartExport() void CmdPartExport::activated(int iMsg) { QStringList filter; - filter << QObject::tr("All CAD Files (*.stp *.step *.igs *.iges *.brp *.brep)"); - filter << QObject::tr("STEP (*.stp *.step)"); + filter << QObject::tr("STEP AP203 (*.stp *.step)"); filter << QObject::tr("IGES (*.igs *.iges)"); filter << QObject::tr("BREP (*.brp *.brep)"); - filter << QObject::tr("All Files (*.*)"); QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;"))); if (!fn.isEmpty()) { App::Document* pDoc = getDocument(); if (!pDoc) return; // no document QString ext = QFileInfo(fn).suffix().toLower(); - if (ext == QLatin1String("step") || - ext == QLatin1String("stp") || - ext == QLatin1String("iges") || + if (ext == QLatin1String("iges") || ext == QLatin1String("igs")) { Gui::Application::Instance->exportTo((const char*)fn.toUtf8(),pDoc->getName(),"ImportGui"); } diff --git a/src/Mod/Part/Init.py b/src/Mod/Part/Init.py index 939723dbf..c50c2d287 100644 --- a/src/Mod/Part/Init.py +++ b/src/Mod/Part/Init.py @@ -43,6 +43,12 @@ ParGrp.SetString("WorkBenchName", "Part Design") ParGrp.SetString("WorkBenchModule", "PartWorkbench.py") -FreeCAD.addImportType("CAD formats (*.igs *.iges *.step *.stp *.brep *.brp)","Part") -FreeCAD.addExportType("CAD formats (*.igs *.iges *.step *.stp *.brep *.brp)","Part") +#FreeCAD.addImportType("CAD formats (*.igs *.iges *.step *.stp *.brep *.brp)","Part") +#FreeCAD.addExportType("CAD formats (*.igs *.iges *.step *.stp *.brep *.brp)","Part") +FreeCAD.addImportType("BREP format (*.brep *.brp)","Part") +FreeCAD.addExportType("BREP format (*.brep *.brp)","Part") +FreeCAD.addImportType("IGES format (*.iges *.igs)","Part") +FreeCAD.addExportType("IGES format (*.iges *.igs)","Part") +FreeCAD.addImportType("STEP AP214 format (*.step *.stp)","ImportGui") +FreeCAD.addExportType("STEP AP214 format (*.step *.stp)","ImportGui")