App: add method DocumentObject::getFirstParent()
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user