Sketcher: Python interface to SketchObject constraint state

This commit is contained in:
Abdullah Tahiri
2019-06-22 06:44:26 +02:00
committed by abdullahtahiriyo
parent e06e03dccb
commit f45d0e54c0
2 changed files with 66 additions and 0 deletions

View File

@@ -133,6 +133,21 @@
<UserDocu>toggle the VirtualSpace status of a constraint</UserDocu>
</Documentation>
</Methode>
<Methode Name="setActive">
<Documentation>
<UserDocu>sets the constraint on/off (enforced or not)</UserDocu>
</Documentation>
</Methode>
<Methode Name="getActive">
<Documentation>
<UserDocu>Get the constraint status (enforced or not)</UserDocu>
</Documentation>
</Methode>
<Methode Name="toggleActive">
<Documentation>
<UserDocu>toggle the active status of constraint (enforced or not)</UserDocu>
</Documentation>
</Methode>
<Methode Name="movePoint">
<Documentation>
<UserDocu>

View File

@@ -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;