Skip to content

Commit

Permalink
App: [skip ci] expose functions to Python to get status string of a f…
Browse files Browse the repository at this point in the history
…eature and whether it's valid
  • Loading branch information
wwmayer committed Nov 12, 2020
1 parent 4756686 commit b560861
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/App/DocumentObjectPy.xml
Expand Up @@ -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>
Expand Down
28 changes: 28 additions & 0 deletions src/App/DocumentObjectPyImp.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit b560861

Please sign in to comment.