From 4bd9515bf57b35628c52194985c64def685db423 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Mon, 3 Apr 2023 13:54:25 +1000 Subject: [PATCH] Fix #2924. IfcElements default to a null predefined type so they can inherit where possible. --- .../ifcopenshell/api/root/create_entity.py | 4 ++-- src/ifcopenshell-python/test/api/root/test_create_entity.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/root/create_entity.py b/src/ifcopenshell-python/ifcopenshell/api/root/create_entity.py index 0e728be75c..3d4c317df8 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/root/create_entity.py +++ b/src/ifcopenshell-python/ifcopenshell/api/root/create_entity.py @@ -100,7 +100,7 @@ class Usecase: return element def handle_2x3_defaults(self, element): - if element.is_a("IfcElement") or element.is_a("IfcElementType"): + if element.is_a("IfcElementType"): if hasattr(element, "PredefinedType") and not element.PredefinedType: element.PredefinedType = "NOTDEFINED" @@ -117,7 +117,7 @@ class Usecase: element.Sizeable = False def handle_4_defaults(self, element): - if element.is_a("IfcElement") or element.is_a("IfcElementType"): + if element.is_a("IfcElementType"): if hasattr(element, "PredefinedType") and not element.PredefinedType: element.PredefinedType = "NOTDEFINED" diff --git a/src/ifcopenshell-python/test/api/root/test_create_entity.py b/src/ifcopenshell-python/test/api/root/test_create_entity.py index 55a327b6ef..49fc0891c2 100644 --- a/src/ifcopenshell-python/test/api/root/test_create_entity.py +++ b/src/ifcopenshell-python/test/api/root/test_create_entity.py @@ -32,7 +32,7 @@ class TestCreateEntity(test.bootstrap.IFC4): def test_handling_predefined_types(self): element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall", name="Foo") - assert element.PredefinedType == "NOTDEFINED" + assert element.PredefinedType is None element = ifcopenshell.api.run( "root.create_entity", self.file, ifc_class="IfcWall", predefined_type="SHEAR", name="Foo" ) @@ -54,6 +54,8 @@ class TestCreateEntity(test.bootstrap.IFC4): assert element.ProcessType == "Foobar" def test_setting_default_values_for_validity(self): + element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType", name="Foo") + assert element.PredefinedType == "NOTDEFINED" element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDoorStyle", name="Foo") assert element.OperationType == "NOTDEFINED" assert element.ConstructionType == "NOTDEFINED"