Add IsGroupedBy in function get_decomposition (#2513)

* Add IsGroupedBy in function get_decomposition

selector example : "@ .IfcZone & .IfcSpace"

* Update element.py

* Change name function get_group

get_group to get_grouped_by
This commit is contained in:
Boris Brangeon
2022-10-19 09:48:55 +02:00
committed by GitHub
parent ec955ca717
commit b2c5153c1c
@@ -376,7 +376,27 @@ def get_decomposition(element):
results.append(rel.RelatedBuildingElement)
return results
def get_grouped_by(element):
"""
Retrieves all subelements of an element based on the group.
:param element: The IFC element
:return: All subelements of the group
Example::
element = file.by_type("IfcGroup")[0]
subelements = ifcopenshell.util.element.get_group(element)
"""
queue = [element]
results = []
while queue:
element = queue.pop()
for rel in getattr(element, "IsGroupedBy", []):
queue.extend(rel.RelatedObjects)
results.extend(rel.RelatedObjects)
return results
def get_aggregate(element):
"""
Retrieves the aggregate of an element.