Minor fix.

This commit is contained in:
Dion Moult
2021-11-16 17:52:08 +11:00
parent 43869c33f6
commit 2120653104
5 changed files with 68 additions and 30 deletions
@@ -81,6 +81,8 @@ def get_type(element):
def get_types(type):
for rel in getattr(type, "Types", []):
return rel.RelatedObjects
for rel in getattr(type, "ObjectTypeOf", []):
return rel.RelatedObjects
return []
@@ -144,6 +144,14 @@ class TestGetTypes(test.bootstrap.IFC4):
assert subject.get_types(element_type) == (element,)
class TestGetTypesIFC2X3(test.bootstrap.IFC2X3):
def test_getting_the_type_of_a_product(self):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
ifcopenshell.api.run("type.assign_type", self.file, related_object=element, relating_type=element_type)
assert subject.get_types(element_type) == (element,)
class TestGetMaterial(test.bootstrap.IFC4):
def test_getting_the_material_of_a_product(self):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")