diff --git a/src/App/DocumentObjectPy.xml b/src/App/DocumentObjectPy.xml index 03e993d874..bc1493fc6c 100644 --- a/src/App/DocumentObjectPy.xml +++ b/src/App/DocumentObjectPy.xml @@ -65,6 +65,20 @@ recompute(recursive=False): Recomputes this object + + + 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 'Touched' will be returned, +'Valid' otherwise. + + + + + + Returns True if the object is valid, False otherwise + + diff --git a/src/App/DocumentObjectPyImp.cpp b/src/App/DocumentObjectPyImp.cpp index ac5ec8db08..618968d42f 100644 --- a/src/App/DocumentObjectPyImp.cpp +++ b/src/App/DocumentObjectPyImp.cpp @@ -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;