mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-12 22:43:41 +00:00
You can now get decompositions non-recursively in element utilities
This commit is contained in:
@@ -609,14 +609,16 @@ def get_referenced_structures(element):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
def get_decomposition(element):
|
def get_decomposition(element, is_recursive=True):
|
||||||
"""
|
"""
|
||||||
Retrieves all subelements of an element based on the spatial decomposition
|
Retrieves all subelements of an element based on the spatial decomposition
|
||||||
hierarchy. This includes all subspaces and elements contained in subspaces,
|
hierarchy. This includes all subspaces and elements contained in subspaces,
|
||||||
parts of an aggreate, all openings, and all fills of any openings.
|
parts of an aggreate, all openings, and all fills of any openings.
|
||||||
|
|
||||||
:param element: The IFC element
|
:param element: The IFC element
|
||||||
|
:type element: ifcopenshell.entity_instance.entity_instance
|
||||||
:return: The decomposition of the element
|
:return: The decomposition of the element
|
||||||
|
:rtype: list[ifcopenshell.entity_instance.entity_instance]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
@@ -644,6 +646,8 @@ def get_decomposition(element):
|
|||||||
for rel in getattr(element, "IsNestedBy", []):
|
for rel in getattr(element, "IsNestedBy", []):
|
||||||
queue.extend(rel.RelatedObjects)
|
queue.extend(rel.RelatedObjects)
|
||||||
results.extend(rel.RelatedObjects)
|
results.extend(rel.RelatedObjects)
|
||||||
|
if not is_recursive:
|
||||||
|
break
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
@@ -682,7 +686,6 @@ def get_aggregate(element):
|
|||||||
.. code:: python
|
.. code:: python
|
||||||
element = file.by_type("IfcBeam")[0]
|
element = file.by_type("IfcBeam")[0]
|
||||||
aggregate = ifcopenshell.util.element.get_aggregate(element)
|
aggregate = ifcopenshell.util.element.get_aggregate(element)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if hasattr(element, "Decomposes") and element.Decomposes:
|
if hasattr(element, "Decomposes") and element.Decomposes:
|
||||||
return element.Decomposes[0].RelatingObject
|
return element.Decomposes[0].RelatingObject
|
||||||
|
|||||||
Reference in New Issue
Block a user