diff --git a/src/Mod/Part/App/AppPart.cpp b/src/Mod/Part/App/AppPart.cpp index 6c17ceb35..39725a29d 100644 --- a/src/Mod/Part/App/AppPart.cpp +++ b/src/Mod/Part/App/AppPart.cpp @@ -156,6 +156,16 @@ void PartExport initPart() PyModule_AddObject(partModule, "OCCDimensionError", PartExceptionOCCDimensionError); + //rename the types properly to pickle and unpickle them + Part::TopoShapePy ::Type.tp_name = "Part.Shape"; + Part::TopoShapeVertexPy ::Type.tp_name = "Part.Vertex"; + Part::TopoShapeWirePy ::Type.tp_name = "Part.Wire"; + Part::TopoShapeEdgePy ::Type.tp_name = "Part.Edge"; + Part::TopoShapeSolidPy ::Type.tp_name = "Part.Solid"; + Part::TopoShapeFacePy ::Type.tp_name = "Part.Face"; + Part::TopoShapeCompoundPy ::Type.tp_name = "Part.Compound"; + Part::TopoShapeCompSolidPy::Type.tp_name = "Part.CompSolid"; + Part::TopoShapeShellPy ::Type.tp_name = "Part.Shell"; // Add Types to module Base::Interpreter().addType(&Part::TopoShapePy ::Type,partModule,"Shape"); Base::Interpreter().addType(&Part::TopoShapeVertexPy ::Type,partModule,"Vertex"); diff --git a/src/Mod/Part/App/TopoShapePy.xml b/src/Mod/Part/App/TopoShapePy.xml index ab07ed0c3..6b5ee6224 100644 --- a/src/Mod/Part/App/TopoShapePy.xml +++ b/src/Mod/Part/App/TopoShapePy.xml @@ -18,6 +18,16 @@ Sub-elements such as vertices, edges or faces are accessible as: * Edge#, where # is in range(1, number of edges) * Face#, where # is in range(1, number of faces) + + + Serialize the content of this shape to a string in BREP format. + + + + + Deserialize the content of this shape from a string in BREP format. + + Read in an IGES, STEP or BREP file. diff --git a/src/Mod/Part/App/TopoShapePyImp.cpp b/src/Mod/Part/App/TopoShapePyImp.cpp index e28fa73f2..5a965f5ec 100644 --- a/src/Mod/Part/App/TopoShapePyImp.cpp +++ b/src/Mod/Part/App/TopoShapePyImp.cpp @@ -455,6 +455,21 @@ PyObject* TopoShapePy::importBrepFromString(PyObject *args) Py_Return; } +PyObject* TopoShapePy::__getstate__(PyObject *args) { + return exportBrepToString(args); +} + + +PyObject* TopoShapePy::__setstate__(PyObject *args) { + if (! getTopoShapePtr()) { + PyErr_SetString(Base::BaseExceptionFreeCADError,"no c++ object"); + return 0; + } + else { + return importBrepFromString(args); + } +} + PyObject* TopoShapePy::exportStl(PyObject *args) { double deflection = 0;