diff --git a/src/Mod/Sketcher/App/SketchObjectPy.xml b/src/Mod/Sketcher/App/SketchObjectPy.xml index 93df7b4631..e89859e806 100644 --- a/src/Mod/Sketcher/App/SketchObjectPy.xml +++ b/src/Mod/Sketcher/App/SketchObjectPy.xml @@ -133,6 +133,21 @@ toggle the VirtualSpace status of a constraint + + + sets the constraint on/off (enforced or not) + + + + + Get the constraint status (enforced or not) + + + + + toggle the active status of constraint (enforced or not) + + diff --git a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp index 3ef89007d3..eaade9bb50 100644 --- a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp +++ b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp @@ -843,6 +843,57 @@ PyObject* SketchObjectPy::toggleVirtualSpace(PyObject *args) Py_Return; } +PyObject* SketchObjectPy::setActive(PyObject *args) +{ + PyObject* isactive; + int constrid; + + if (!PyArg_ParseTuple(args, "iO!", &constrid, &PyBool_Type, &isactive)) + return 0; + + if (this->getSketchObjectPtr()->setActive(constrid, PyObject_IsTrue(isactive) ? true : false)) { + std::stringstream str; + str << "Not able set active/disabled status for constraint with the given index: " << constrid; + PyErr_SetString(PyExc_ValueError, str.str().c_str()); + return 0; + } + + Py_Return; +} + +PyObject* SketchObjectPy::getActive(PyObject *args) +{ + int constrid; + bool isactive; + + if (!PyArg_ParseTuple(args, "i", &constrid)) + return 0; + + if (this->getSketchObjectPtr()->getActive(constrid, isactive)) { + PyErr_SetString(PyExc_ValueError, "Invalid constraint id"); + return 0; + } + + return Py::new_reference_to(Py::Boolean(isactive)); +} + +PyObject* SketchObjectPy::toggleActive(PyObject *args) +{ + int constrid; + + if (!PyArg_ParseTuple(args, "i", &constrid)) + return 0; + + if (this->getSketchObjectPtr()->toggleActive(constrid)) { + std::stringstream str; + str << "Not able toggle on/off constraint with the given index: " << constrid; + PyErr_SetString(PyExc_ValueError, str.str().c_str()); + return 0; + } + + Py_Return; +} + PyObject* SketchObjectPy::movePoint(PyObject *args) { PyObject *pcObj;