mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 08:45:22 +00:00
Fix bug where filtering did not work for indirectly spatially contained elements
This commit is contained in:
@@ -79,6 +79,9 @@ def get_material(element, should_skip_usage=False):
|
|||||||
|
|
||||||
|
|
||||||
def get_container(element):
|
def get_container(element):
|
||||||
|
aggregate = get_aggregate(element)
|
||||||
|
if aggregate:
|
||||||
|
return get_container(aggregate)
|
||||||
if hasattr(element, "ContainedInStructure") and element.ContainedInStructure:
|
if hasattr(element, "ContainedInStructure") and element.ContainedInStructure:
|
||||||
return element.ContainedInStructure[0].RelatingStructure
|
return element.ContainedInStructure[0].RelatingStructure
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import test.bootstrap
|
|||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
|
|
||||||
|
|
||||||
class TestEditStyleColours(test.bootstrap.IFC4):
|
class TestEditSurfaceStyle(test.bootstrap.IFC4):
|
||||||
def test_editing_a_shading_style(self):
|
def test_editing_a_shading_style(self):
|
||||||
colour = self.file.createIfcColourRgb(None, 0, 0, 0)
|
colour = self.file.createIfcColourRgb(None, 0, 0, 0)
|
||||||
style = self.file.createIfcSurfaceStyleShading(colour)
|
style = self.file.createIfcSurfaceStyleShading(colour)
|
||||||
|
|||||||
@@ -165,6 +165,14 @@ class TestGetContainerIFC4(test.bootstrap.IFC4):
|
|||||||
ifcopenshell.api.run("spatial.assign_container", self.file, product=element, relating_structure=building)
|
ifcopenshell.api.run("spatial.assign_container", self.file, product=element, relating_structure=building)
|
||||||
assert ifcopenshell.util.element.get_container(element) == building
|
assert ifcopenshell.util.element.get_container(element) == building
|
||||||
|
|
||||||
|
def test_getting_an_indirect_spatial_container_of_an_element(self):
|
||||||
|
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||||
|
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcElementAssembly")
|
||||||
|
building = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||||
|
ifcopenshell.api.run("spatial.assign_container", self.file, product=element, relating_structure=building)
|
||||||
|
ifcopenshell.api.run("aggregate.assign_object", self.file, product=subelement, relating_object=element)
|
||||||
|
assert ifcopenshell.util.element.get_container(subelement) == building
|
||||||
|
|
||||||
|
|
||||||
class TestGetAggregateIFC4(test.bootstrap.IFC4):
|
class TestGetAggregateIFC4(test.bootstrap.IFC4):
|
||||||
def test_getting_the_containing_aggregate_of_a_subelement(self):
|
def test_getting_the_containing_aggregate_of_a_subelement(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user