diff --git a/src/Mod/Import/App/AppImportPy.cpp b/src/Mod/Import/App/AppImportPy.cpp index 8ae59ee3ad..0aacf3b16b 100644 --- a/src/Mod/Import/App/AppImportPy.cpp +++ b/src/Mod/Import/App/AppImportPy.cpp @@ -383,10 +383,9 @@ private: std::string filePath; std::string layerName; const char* optionSource = nullptr; - char* defaultOptions = "User parameter:BaseApp/Preferences/Mod/Draft"; + char* defaultOptions = "User parameter:BaseApp/Preferences/Mod/Import"; char* useOptionSource = nullptr; - if (PyArg_ParseTuple(args.ptr(), "O!et|s", &(PyList_Type) ,&shapeObj, "utf-8",&fname, &optionSource)) { filePath = std::string(fname); layerName = "none"; @@ -402,13 +401,16 @@ private: writer.setOptionSource(useOptionSource); writer.setOptions(); writer.setLayerName(layerName); + writer.init(); Py::Sequence list(shapeObj); for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { if (PyObject_TypeCheck((*it).ptr(), &(Part::TopoShapePy::Type))) { - const TopoDS_Shape& shape = static_cast((*it).ptr())->getTopoShapePtr()->getShape(); + Part::TopoShape* ts = static_cast((*it).ptr())->getTopoShapePtr(); + TopoDS_Shape shape = ts->getShape(); writer.exportShape(shape); } } + writer.endRun(); } catch (const Base::Exception& e) { throw Py::RuntimeError(e.what()); @@ -433,9 +435,11 @@ private: writer.setOptionSource(useOptionSource); writer.setOptions(); writer.setLayerName(layerName); + writer.init(); Part::TopoShape* obj = static_cast(shapeObj)->getTopoShapePtr(); TopoDS_Shape shape = obj->getShape(); writer.exportShape(shape); + writer.endRun(); } catch (const Base::Exception& e) { throw Py::RuntimeError(e.what()); @@ -453,7 +457,7 @@ private: std::string filePath; std::string layerName; const char* optionSource = nullptr; - char* defaultOptions = "User parameter:BaseApp/Preferences/Mod/Draft"; + char* defaultOptions = "User parameter:BaseApp/Preferences/Mod/Import"; char* useOptionSource = nullptr; @@ -472,6 +476,7 @@ private: writer.setOptionSource(useOptionSource); writer.setOptions(); writer.setLayerName(layerName); + writer.init(); Py::Sequence list(docObj); for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { if (PyObject_TypeCheck((*it).ptr(), &(Part::PartFeaturePy::Type))) { @@ -484,6 +489,7 @@ private: writer.exportShape(shape); } } + writer.endRun(); } catch (const Base::Exception& e) { throw Py::RuntimeError(e.what()); @@ -508,12 +514,14 @@ private: writer.setOptionSource(useOptionSource); writer.setOptions(); writer.setLayerName(layerName); + writer.init(); App::DocumentObject* obj = static_cast(docObj)->getDocumentObjectPtr(); Part::Feature* part = static_cast(obj); layerName = part->getNameInDocument(); writer.setLayerName(layerName); const TopoDS_Shape& shape = part->Shape.getValue(); writer.exportShape(shape); + writer.endRun(); } catch (const Base::Exception& e) { throw Py::RuntimeError(e.what());