From c79ac8d1fc03cff3369b5d2f5f7dc9ed70510182 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Mon, 21 Dec 2020 16:43:48 +0100 Subject: [PATCH] Sketcher: Implement Python function getConstruction(geoId) to retrieve geometry construction status --- src/Mod/Sketcher/App/SketchObjectPy.xml | 5 +++++ src/Mod/Sketcher/App/SketchObjectPyImp.cpp | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/Mod/Sketcher/App/SketchObjectPy.xml b/src/Mod/Sketcher/App/SketchObjectPy.xml index 10ae0e8748..86b984fc23 100644 --- a/src/Mod/Sketcher/App/SketchObjectPy.xml +++ b/src/Mod/Sketcher/App/SketchObjectPy.xml @@ -48,6 +48,11 @@ set construction mode of a geometry on or off + + + returns the construction mode of a geometry + + add a constraint to the sketch diff --git a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp index 72be7b3922..7cfd04577a 100644 --- a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp +++ b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp @@ -280,6 +280,24 @@ PyObject* SketchObjectPy::setConstruction(PyObject *args) Py_Return; } +PyObject* SketchObjectPy::getConstruction(PyObject *args) +{ + int Index; + if (!PyArg_ParseTuple(args, "i", &Index)) + return 0; + + auto gf = this->getSketchObjectPtr()->getGeometryFacade(Index); + + if(gf) + return Py::new_reference_to(Py::Boolean(gf->getConstruction())); + + std::stringstream str; + str << "Not able to retrieve construction mode of a geometry with the given index: " << Index; + PyErr_SetString(PyExc_ValueError, str.str().c_str()); + return 0; + +} + PyObject* SketchObjectPy::addConstraint(PyObject *args) { PyObject *pcObj;