mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Decomposition mode now selects all children (not parenting) to move a host and all children easily
This commit is contained in:
@@ -323,7 +323,9 @@ def get_container(element, should_get_direct=False):
|
||||
|
||||
def get_referenced_structures(element):
|
||||
"""
|
||||
Retreives a list of referenced structural elements
|
||||
Retreives a list of referenced spatial elements, typically useful for
|
||||
multistorey elements or elements that span multiple spaces or in-between
|
||||
spaces.
|
||||
|
||||
:param element: The IFC element
|
||||
:type element: ifcopenshell.entity_instance.entity_instance
|
||||
@@ -340,7 +342,9 @@ def get_referenced_structures(element):
|
||||
|
||||
def get_decomposition(element):
|
||||
"""
|
||||
Retrieves the decomposition of an element.
|
||||
Retrieves all subelements of an element based on the spatial decomposition
|
||||
hierarchy. This includes all subspaces and elements contained in subspaces,
|
||||
parts of an aggreate, all openings, and all fills of any openings.
|
||||
|
||||
:param element: The IFC element
|
||||
:return: The decomposition of the element
|
||||
@@ -360,6 +364,12 @@ def get_decomposition(element):
|
||||
for rel in getattr(element, "IsDecomposedBy", []):
|
||||
queue.extend(rel.RelatedObjects)
|
||||
results.extend(rel.RelatedObjects)
|
||||
for rel in getattr(element, "HasOpenings", []):
|
||||
queue.append(rel.RelatedOpeningElement)
|
||||
results.append(rel.RelatedOpeningElement)
|
||||
for rel in getattr(element, "HasFillings", []):
|
||||
queue.append(rel.RelatedBuildingElement)
|
||||
results.append(rel.RelatedBuildingElement)
|
||||
return results
|
||||
|
||||
|
||||
|
||||
@@ -561,6 +561,16 @@ class TestGetDecompositionIFC4(test.bootstrap.IFC4):
|
||||
assert element in results
|
||||
assert subelement in results
|
||||
|
||||
def test_getting_openings_and_fills_of_an_element(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
|
||||
subsubelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWindow")
|
||||
ifcopenshell.api.run("void.add_opening", self.file, element=element, opening=subelement)
|
||||
ifcopenshell.api.run("void.add_filling", self.file, element=subsubelement, opening=subelement)
|
||||
results = subject.get_decomposition(element)
|
||||
assert subelement in results
|
||||
assert subsubelement in results
|
||||
|
||||
|
||||
class TestGetAggregateIFC4(test.bootstrap.IFC4):
|
||||
def test_getting_the_containing_aggregate_of_a_subelement(self):
|
||||
|
||||
Reference in New Issue
Block a user