App: expose function getParent() to Python

This commit is contained in:
wmayer
2023-05-15 23:40:25 +02:00
parent 41e6758bc0
commit 1ade42e634
2 changed files with 27 additions and 0 deletions

View File

@@ -182,6 +182,15 @@ Return -1 if element visibility is not supported or element not found, 0 if invi
in a single group, hence only a single return value.</UserDocu>
</Documentation>
</Methode>
<Methode Name="getParent">
<Documentation>
<UserDocu>Returns the group the object is in or None if it is not part of a group.
Note that an object can only be in a single group, hence only a single return
value.
The parent can be a simple group as with getParentGroup() or a
GeoFeature group as with getParentGeoFeatureGroup().</UserDocu>
</Documentation>
</Methode>
<Methode Name="getPathsByOutList">
<Documentation>
<UserDocu>Get all paths from this object to another object following the OutList.</UserDocu>

View File

@@ -673,6 +673,24 @@ PyObject* DocumentObjectPy::getParentGeoFeatureGroup(PyObject *args)
}
}
PyObject* DocumentObjectPy::getParent(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
try {
auto grp = getDocumentObjectPtr()->getFirstParent();
if(!grp) {
Py_INCREF(Py_None);
return Py_None;
}
return grp->getPyObject();
}
catch (const Base::Exception& e) {
throw Py::RuntimeError(e.what());
}
}
Py::Boolean DocumentObjectPy::getMustExecute() const
{
try {