From e1bf2045dd50eacade92b9e4683d406dc480701d Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Tue, 2 Jan 2018 15:50:00 +0100 Subject: [PATCH] Sketcher: Overload delConstraintonPoint Python to allow deletion on GeoId and Pos --- src/Mod/Sketcher/App/SketchObjectPyImp.cpp | 32 +++++++++++++++++----- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp index 2b65a0229d..5bd4e89864 100644 --- a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp +++ b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp @@ -479,15 +479,33 @@ PyObject* SketchObjectPy::delExternal(PyObject *args) PyObject* SketchObjectPy::delConstraintOnPoint(PyObject *args) { - int Index; - if (!PyArg_ParseTuple(args, "i", &Index)) + int Index, pos=-1; + if (!PyArg_ParseTuple(args, "i|i", &Index, &pos)) return 0; - if (this->getSketchObjectPtr()->delConstraintOnPoint(Index)) { - std::stringstream str; - str << "Not able to delete a constraint on point with the given index: " << Index; - PyErr_SetString(PyExc_ValueError, str.str().c_str()); - return 0; + if(pos>=0 && pos<3) { // Sketcher::none Sketcher::mid + if (this->getSketchObjectPtr()->delConstraintOnPoint(Index,(Sketcher::PointPos)pos)) { + std::stringstream str; + str << "Not able to delete a constraint on point with the given index: " << Index; + PyErr_SetString(PyExc_ValueError, str.str().c_str()); + return 0; + } + } + else if (pos==-1) { + + if (this->getSketchObjectPtr()->delConstraintOnPoint(Index)) { + std::stringstream str; + str << "Not able to delete a constraint on point with the given index: " << Index; + PyErr_SetString(PyExc_ValueError, str.str().c_str()); + return 0; + } + } + else { + std::stringstream str; + str << "Wrong PointPos argument"; + PyErr_SetString(PyExc_ValueError, str.str().c_str()); + return 0; + } Py_Return;