rename python classes for shapes and
implememnt __getstate__ and __setstate__ to enable pickling issue #1948
This commit is contained in:
parent
79173e37cd
commit
8ec87dbdf2
|
@ -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");
|
||||
|
|
|
@ -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)</UserDocu>
|
||||
</Documentation>
|
||||
<Methode Name="__getstate__" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>Serialize the content of this shape to a string in BREP format.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="__setstate__">
|
||||
<Documentation>
|
||||
<UserDocu>Deserialize the content of this shape from a string in BREP format.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="read">
|
||||
<Documentation>
|
||||
<UserDocu>Read in an IGES, STEP or BREP file.</UserDocu>
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user