diff --git a/src/Mod/Fem/App/AppFemPy.cpp b/src/Mod/Fem/App/AppFemPy.cpp index 2a89e8e51c..47554facb4 100644 --- a/src/Mod/Fem/App/AppFemPy.cpp +++ b/src/Mod/Fem/App/AppFemPy.cpp @@ -103,7 +103,7 @@ public: ); #endif add_varargs_method("show",&Module::show, - "show(shape) -- Add the shape to the active document or create one if no document exists." + "show(shape,[string]) -- Add the mesh to the active document or create one if no document exists." ); initialize("This module is the Fem module."); // register with Python } @@ -299,7 +299,8 @@ private: Py::Object show(const Py::Tuple& args) { PyObject *pcObj; - if (!PyArg_ParseTuple(args.ptr(), "O!", &(FemMeshPy::Type), &pcObj)) + char *name = "Mesh"; + if (!PyArg_ParseTuple(args.ptr(), "O!|s", &(FemMeshPy::Type), &pcObj, &name)) throw Py::Exception(); App::Document *pcDoc = App::GetApplication().getActiveDocument(); @@ -307,9 +308,9 @@ private: pcDoc = App::GetApplication().newDocument(); FemMeshPy* pShape = static_cast(pcObj); - Fem::FemMeshObject *pcFeature = (Fem::FemMeshObject *)pcDoc->addObject("Fem::FemMeshObject", "Mesh"); + Fem::FemMeshObject *pcFeature = static_cast + (pcDoc->addObject("Fem::FemMeshObject", name)); // copy the data - //TopoShape* shape = new MeshObject(*pShape->getTopoShapeObjectPtr()); pcFeature->FemMesh.setValue(*(pShape->getFemMeshPtr())); pcDoc->recompute(); diff --git a/src/Mod/Mesh/App/AppMeshPy.cpp b/src/Mod/Mesh/App/AppMeshPy.cpp index fcc3e23bff..157596e4a5 100644 --- a/src/Mod/Mesh/App/AppMeshPy.cpp +++ b/src/Mod/Mesh/App/AppMeshPy.cpp @@ -85,7 +85,7 @@ public: "compressed.\n" ); add_varargs_method("show",&Module::show, - "Put a mesh object in the active document or creates one if needed" + "show(shape,[string]) -- Add the mesh to the active document or create one if no document exists." ); add_varargs_method("createBox",&Module::createBox, "Create a solid mesh box" @@ -359,14 +359,15 @@ private: Py::Object show(const Py::Tuple& args) { PyObject *pcObj; - if (!PyArg_ParseTuple(args.ptr(), "O!", &(MeshPy::Type), &pcObj)) + char *name = "Mesh"; + if (!PyArg_ParseTuple(args.ptr(), "O!|s", &(MeshPy::Type), &pcObj, &name)) throw Py::Exception(); App::Document *pcDoc = App::GetApplication().getActiveDocument(); if (!pcDoc) pcDoc = App::GetApplication().newDocument(); MeshPy* pMesh = static_cast(pcObj); - Mesh::Feature *pcFeature = (Mesh::Feature *)pcDoc->addObject("Mesh::Feature", "Mesh"); + Mesh::Feature *pcFeature = static_cast(pcDoc->addObject("Mesh::Feature", name)); Mesh::MeshObject* mo = pMesh->getMeshObjectPtr(); if (!mo) { throw Py::Exception(PyExc_ReferenceError, "object doesn't reference a valid mesh"); diff --git a/src/Mod/Part/App/AppPartPy.cpp b/src/Mod/Part/App/AppPartPy.cpp index b758ae652e..944a9868c1 100644 --- a/src/Mod/Part/App/AppPartPy.cpp +++ b/src/Mod/Part/App/AppPartPy.cpp @@ -616,9 +616,8 @@ private: if (!pcDoc) pcDoc = App::GetApplication().newDocument(); TopoShapePy* pShape = static_cast(pcObj); - Part::Feature *pcFeature = (Part::Feature *)pcDoc->addObject("Part::Feature", name); + Part::Feature *pcFeature = static_cast(pcDoc->addObject("Part::Feature", name)); // copy the data - //TopoShape* shape = new MeshObject(*pShape->getTopoShapeObjectPtr()); pcFeature->Shape.setValue(pShape->getTopoShapePtr()->getShape()); pcDoc->recompute(); diff --git a/src/Mod/Path/App/AppPathPy.cpp b/src/Mod/Path/App/AppPathPy.cpp index a42721d3c5..2ffce12f25 100644 --- a/src/Mod/Path/App/AppPathPy.cpp +++ b/src/Mod/Path/App/AppPathPy.cpp @@ -113,7 +113,7 @@ public: "read(filename,[document]): Imports a GCode file into the given document" ); add_varargs_method("show",&Module::show, - "show(path): Add the path to the active document or create one if no document exists" + "show(path,[string]): Add the path to the active document or create one if no document exists" ); add_varargs_method("fromShape",&Module::fromShape, "fromShape(Shape): Returns a Path object from a Part Shape" @@ -217,15 +217,16 @@ private: Py::Object show(const Py::Tuple& args) { PyObject *pcObj; - if (!PyArg_ParseTuple(args.ptr(), "O!", &(PathPy::Type), &pcObj)) + char *name = "Path"; + if (!PyArg_ParseTuple(args.ptr(), "O!|s", &(PathPy::Type), &pcObj, &name)) throw Py::Exception(); try { - App::Document *pcDoc = App::GetApplication().getActiveDocument(); + App::Document *pcDoc = App::GetApplication().getActiveDocument(); if (!pcDoc) pcDoc = App::GetApplication().newDocument(); PathPy* pPath = static_cast(pcObj); - Path::Feature *pcFeature = (Path::Feature *)pcDoc->addObject("Path::Feature", "Path"); + Path::Feature *pcFeature = static_cast(pcDoc->addObject("Path::Feature", name)); Path::Toolpath* pa = pPath->getToolpathPtr(); if (!pa) { throw Py::Exception(PyExc_ReferenceError, "object doesn't reference a valid path"); diff --git a/src/Mod/Points/App/AppPointsPy.cpp b/src/Mod/Points/App/AppPointsPy.cpp index 80713402da..6ed47bbbc1 100644 --- a/src/Mod/Points/App/AppPointsPy.cpp +++ b/src/Mod/Points/App/AppPointsPy.cpp @@ -64,7 +64,8 @@ public: ); add_varargs_method("export",&Module::exporter ); - add_varargs_method("show",&Module::show + add_varargs_method("show",&Module::show, + "show(points,[string]) -- Add the points to the active document or create one if no document exists." ); initialize("This module is the Points module."); // register with Python } @@ -381,7 +382,8 @@ private: Py::Object show(const Py::Tuple& args) { PyObject *pcObj; - if (!PyArg_ParseTuple(args.ptr(), "O!", &(PointsPy::Type), &pcObj)) + char *name = "Points"; + if (!PyArg_ParseTuple(args.ptr(), "O!|s", &(PointsPy::Type), &pcObj, &name)) throw Py::Exception(); try { @@ -389,11 +391,9 @@ private: if (!pcDoc) pcDoc = App::GetApplication().newDocument(); PointsPy* pPoints = static_cast(pcObj); - Points::Feature *pcFeature = (Points::Feature *)pcDoc->addObject("Points::Feature", "Points"); + Points::Feature *pcFeature = static_cast(pcDoc->addObject("Points::Feature", name)); // copy the data - //TopoShape* shape = new MeshObject(*pShape->getTopoShapeObjectPtr()); pcFeature->Points.setValue(*(pPoints->getPointKernelPtr())); - //pcDoc->recompute(); } catch (const Base::Exception& e) { throw Py::RuntimeError(e.what());