App: [skip ci] expose functions to Python to get status string of a feature and whether it's valid

This commit is contained in:
wmayer
2020-11-12 15:46:40 +01:00
parent 837cfa8f75
commit 85c1fa1739
2 changed files with 42 additions and 0 deletions

View File

@@ -65,6 +65,20 @@
<UserDocu>recompute(recursive=False): Recomputes this object</UserDocu>
</Documentation>
</Methode>
<Methode Name="getStatusString" const="True">
<Documentation>
<UserDocu>Returns the status of the object as string.
If the object is invalid its error description will be returned.
If the object is valid but touched then &apos;Touched&apos; will be returned,
&apos;Valid&apos; otherwise.
</UserDocu>
</Documentation>
</Methode>
<Methode Name="isValid" const="True">
<Documentation>
<UserDocu>Returns True if the object is valid, False otherwise</UserDocu>
</Documentation>
</Methode>
<Methode Name="getSubObject" Keyword="true">
<Documentation>
<UserDocu>

View File

@@ -397,6 +397,34 @@ PyObject* DocumentObjectPy::recompute(PyObject *args)
}
}
PyObject* DocumentObjectPy::isValid(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
try {
bool ok = getDocumentObjectPtr()->isValid();
return Py_BuildValue("O", (ok ? Py_True : Py_False));
}
catch (const Base::Exception& e) {
throw Py::RuntimeError(e.what());
}
}
PyObject* DocumentObjectPy::getStatusString(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
try {
Py::String text(getDocumentObjectPtr()->getStatusString());
return Py::new_reference_to(text);
}
catch (const Base::Exception& e) {
throw Py::RuntimeError(e.what());
}
}
PyObject* DocumentObjectPy::getSubObject(PyObject *args, PyObject *keywds)
{
PyObject *obj;