From d99e667e308cd87cc380745d6df341d1c1329792 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Mon, 11 Feb 2019 06:56:37 +0100 Subject: [PATCH] Part: Command to show list of extensions from Python --- src/Mod/Part/App/GeometryPy.xml | 5 +++++ src/Mod/Part/App/GeometryPyImp.cpp | 33 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/Mod/Part/App/GeometryPy.xml b/src/Mod/Part/App/GeometryPy.xml index 1862eb89d8..7d7d0bd335 100644 --- a/src/Mod/Part/App/GeometryPy.xml +++ b/src/Mod/Part/App/GeometryPy.xml @@ -63,6 +63,11 @@ It describes the common behavior of these objects when: Sets a geometry extension of the indicated type. + + + Returns a list with information about the geometry extensions. + + Defines this geometry as a construction one which diff --git a/src/Mod/Part/App/GeometryPyImp.cpp b/src/Mod/Part/App/GeometryPyImp.cpp index 5ce069cd2d..06a3cce2ce 100644 --- a/src/Mod/Part/App/GeometryPyImp.cpp +++ b/src/Mod/Part/App/GeometryPyImp.cpp @@ -291,6 +291,39 @@ PyObject* GeometryPy::getExtension(PyObject *args) return 0; } +PyObject* GeometryPy::showExtensions(PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")){ + PyErr_SetString(PartExceptionOCCError, "No arguments were expected"); + return NULL; + } + + try { + const std::vector> ext = this->getGeometryPtr()->getExtensions(); + + + Py::Tuple tuple(ext.size()); + + for (std::size_t i=0; i p = ext[i].lock(); + + if(p) { + str << "<" << p->getTypeId().getName() << ", \"" << p->getName() << "\">"; + + tuple.setItem(i, Py::String(str.str())); + } + } + + return Py::new_reference_to(tuple); + } + catch(Base::ValueError e) { + PyErr_SetString(PartExceptionOCCError, e.what()); + return 0; + } + +} + Py::Boolean GeometryPy::getConstruction(void) const { return Py::Boolean(getGeometryPtr()->Construction);