Sketcher: Overload delConstraintonPoint Python to allow deletion on GeoId and Pos

This commit is contained in:
Abdullah Tahiri
2018-01-02 15:50:00 +01:00
committed by wmayer
parent af45008a5e
commit e1bf2045dd

View File

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