mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 13:46:54 +00:00
Fix bug in get_container not passing specified ifc_class to the parent #6155
This commit is contained in:
@@ -935,7 +935,7 @@ def get_container(
|
|||||||
return container
|
return container
|
||||||
container = get_aggregate(container)
|
container = get_aggregate(container)
|
||||||
elif parent := get_parent(element):
|
elif parent := get_parent(element):
|
||||||
return get_container(parent, should_get_direct)
|
return get_container(parent, should_get_direct, ifc_class)
|
||||||
|
|
||||||
|
|
||||||
def get_referenced_structures(element: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_instance]:
|
def get_referenced_structures(element: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_instance]:
|
||||||
|
|||||||
@@ -793,6 +793,26 @@ class TestGetContainerIFC4(test.bootstrap.IFC4):
|
|||||||
ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
|
ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
|
||||||
assert subject.get_container(subelement, should_get_direct=True) is None
|
assert subject.get_container(subelement, should_get_direct=True) is None
|
||||||
|
|
||||||
|
def test_getting_the_specific_spatial_container_of_an_element(self):
|
||||||
|
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||||
|
building = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
|
||||||
|
storey = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuildingStorey")
|
||||||
|
ifcopenshell.api.aggregate.assign_object(self.file, products=[storey], relating_object=building)
|
||||||
|
ifcopenshell.api.spatial.assign_container(self.file, products=[element], relating_structure=storey)
|
||||||
|
assert subject.get_container(element, ifc_class="IfcBuilding") == building
|
||||||
|
assert subject.get_container(element, ifc_class="IfcSite") == None
|
||||||
|
|
||||||
|
def test_getting_the_specific_spatial_container_of_an_element_indirectly(self):
|
||||||
|
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcElementAssembly")
|
||||||
|
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||||
|
ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
|
||||||
|
building = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
|
||||||
|
storey = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuildingStorey")
|
||||||
|
ifcopenshell.api.aggregate.assign_object(self.file, products=[storey], relating_object=building)
|
||||||
|
ifcopenshell.api.spatial.assign_container(self.file, products=[element], relating_structure=storey)
|
||||||
|
assert subject.get_container(subelement, ifc_class="IfcBuilding") == building
|
||||||
|
assert subject.get_container(subelement, ifc_class="IfcSite") == None
|
||||||
|
|
||||||
|
|
||||||
class TestGetReferencedStructures(test.bootstrap.IFC4):
|
class TestGetReferencedStructures(test.bootstrap.IFC4):
|
||||||
def test_getting_references_of_an_element(self):
|
def test_getting_references_of_an_element(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user