Sketcher: expose the LabelDistance and LabelPosition members of Constraint to Python

This commit is contained in:
wmayer
2024-02-22 13:56:30 +01:00
committed by wwmayer
parent 8d8d47df70
commit 78ffa29629
6 changed files with 223 additions and 0 deletions

View File

@@ -1041,6 +1041,74 @@ PyObject* SketchObjectPy::toggleActive(PyObject* args)
Py_Return;
}
PyObject* SketchObjectPy::getLabelPosition(PyObject* args)
{
int constrid {};
float pos {};
if (!PyArg_ParseTuple(args, "i", &constrid)) {
return nullptr;
}
if (this->getSketchObjectPtr()->getLabelPosition(constrid, pos)) {
PyErr_SetString(PyExc_ValueError, "Invalid constraint id");
return nullptr;
}
return Py::new_reference_to(Py::Float(pos));
}
PyObject* SketchObjectPy::setLabelPosition(PyObject* args)
{
int constrid {};
float pos {};
if (!PyArg_ParseTuple(args, "if", &constrid, &pos)) {
return nullptr;
}
if (this->getSketchObjectPtr()->setLabelPosition(constrid, pos)) {
PyErr_SetString(PyExc_ValueError, "Invalid constraint id");
return nullptr;
}
Py_Return;
}
PyObject* SketchObjectPy::getLabelDistance(PyObject* args)
{
int constrid {};
float dist {};
if (!PyArg_ParseTuple(args, "i", &constrid)) {
return nullptr;
}
if (this->getSketchObjectPtr()->getLabelDistance(constrid, dist)) {
PyErr_SetString(PyExc_ValueError, "Invalid constraint id");
return nullptr;
}
return Py::new_reference_to(Py::Float(dist));
}
PyObject* SketchObjectPy::setLabelDistance(PyObject* args)
{
int constrid {};
float dist {};
if (!PyArg_ParseTuple(args, "if", &constrid, &dist)) {
return nullptr;
}
if (this->getSketchObjectPtr()->setLabelDistance(constrid, dist)) {
PyErr_SetString(PyExc_ValueError, "Invalid constraint id");
return nullptr;
}
Py_Return;
}
PyObject* SketchObjectPy::movePoint(PyObject* args)
{
PyObject* pcObj;