App::Link : add getLinkGroup() to ElementLink

This commit is contained in:
PaddleStroke
2024-08-28 15:58:34 +02:00
committed by Yorik van Havre
parent 1822312127
commit 5cb2fd5261
2 changed files with 20 additions and 0 deletions

View File

@@ -2309,6 +2309,24 @@ bool LinkElement::canDelete() const {
return !owner || !owner->getDocument()->getObjectByID(_LinkOwner.getValue());
}
App::Link* LinkElement::getLinkGroup() const
{
std::vector<App::DocumentObject*> inList = getInList();
for (auto* obj : inList) {
auto* link = dynamic_cast<App::Link*>(obj);
if (!link) {
continue;
}
std::vector<App::DocumentObject*> elts = link->ElementList.getValues();
for (auto* elt : elts) {
if (elt == this) {
return link;
}
}
}
return nullptr;
}
//////////////////////////////////////////////////////////////////////////////////////////
namespace App {

View File

@@ -599,6 +599,8 @@ public:
{
_handleChangedPropertyName(reader,TypeName,PropName);
}
App::Link* getLinkGroup() const;
};
using LinkElementPython = App::FeaturePythonT<LinkElement>;