App: add method DocumentObject::getFirstParent()

This commit is contained in:
wmayer
2023-05-13 15:12:49 +02:00
committed by wwmayer
parent fdf5d22a6b
commit 92de5cbb44
2 changed files with 14 additions and 0 deletions

View File

@@ -897,6 +897,17 @@ std::vector<std::pair<App::DocumentObject *,std::string>> DocumentObject::getPar
return ret;
}
App::DocumentObject* DocumentObject::getFirstParent() const
{
for (auto obj : getInList()) {
if (obj->hasExtension(App::GroupExtension::getExtensionClassTypeId(), true)) {
return obj;
}
}
return nullptr;
}
DocumentObject *DocumentObject::getLinkedObject(
bool recursive, Base::Matrix4D *mat, bool transform, int depth) const
{

View File

@@ -383,6 +383,9 @@ public:
///Obtain top parents and subnames of this object using its InList
std::vector<std::pair<App::DocumentObject*,std::string> > getParents(int depth=0) const;
/// Obtain the first parent group of this object
App::DocumentObject* getFirstParent() const;
/** Return the linked object with optional transformation
*
* @param recurse: If false, return the immediate linked object, or else