From 6bbefe94f526052f0b3ec1c81e7af71abc846e71 Mon Sep 17 00:00:00 2001 From: Markus Lampert Date: Mon, 18 Sep 2017 21:34:41 -0700 Subject: [PATCH] Added optional name parameter to Part.show() --- src/Mod/Part/App/AppPartPy.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Mod/Part/App/AppPartPy.cpp b/src/Mod/Part/App/AppPartPy.cpp index 8c5fcd9ee2..b758ae652e 100644 --- a/src/Mod/Part/App/AppPartPy.cpp +++ b/src/Mod/Part/App/AppPartPy.cpp @@ -259,7 +259,7 @@ public: "read(string) -- Load the file and return the shape." ); 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 shape to the active document or create one if no document exists." ); add_varargs_method("makeCompound",&Module::makeCompound, "makeCompound(list) -- Create a compound out of a list of shapes." @@ -607,15 +607,16 @@ private: } Py::Object show(const Py::Tuple& args) { - PyObject *pcObj; - if (!PyArg_ParseTuple(args.ptr(), "O!", &(TopoShapePy::Type), &pcObj)) + PyObject *pcObj = 0; + char *name = "Shape"; + if (!PyArg_ParseTuple(args.ptr(), "O!|s", &(TopoShapePy::Type), &pcObj, &name)) throw Py::Exception(); App::Document *pcDoc = App::GetApplication().getActiveDocument(); if (!pcDoc) pcDoc = App::GetApplication().newDocument(); TopoShapePy* pShape = static_cast(pcObj); - Part::Feature *pcFeature = (Part::Feature *)pcDoc->addObject("Part::Feature", "Shape"); + Part::Feature *pcFeature = (Part::Feature *)pcDoc->addObject("Part::Feature", name); // copy the data //TopoShape* shape = new MeshObject(*pShape->getTopoShapeObjectPtr()); pcFeature->Shape.setValue(pShape->getTopoShapePtr()->getShape());