From 3120b0c6e29fbbe7ef874c8855304b23aaaf520d Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Mon, 12 Sep 2022 23:03:50 +1000 Subject: [PATCH] Add support for IfcTester and predefined properties --- src/ifctester/ifctester/facet.py | 11 ++++++++++- src/ifctester/test/test_facet.py | 23 +++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/ifctester/ifctester/facet.py b/src/ifctester/ifctester/facet.py index 11153e1513..7d6a8588db 100644 --- a/src/ifctester/ifctester/facet.py +++ b/src/ifctester/ifctester/facet.py @@ -464,7 +464,10 @@ class Property(Facet): for prop_entity in self.get_properties(pset_entity): if prop_entity.Name not in props[pset_name].keys(): continue - if prop_entity.is_a("IfcPropertySingleValue"): + if not isinstance(prop_entity, ifcopenshell.entity_instance): + # Predefined properties are special :( + pass + elif prop_entity.is_a("IfcPropertySingleValue"): data_type = prop_entity.NominalValue.is_a() if data_type != self.measure: @@ -640,6 +643,12 @@ class Property(Facet): return pset.Quantities elif pset.is_a("IfcMaterialProperties") or pset.is_a("IfcProfileProperties"): return pset.Properties + elif pset.is_a("IfcPreDefinedPropertySet"): + return [ + type("", (object,), {"Name": k, "Value": v})() + for k, v in pset.get_info().items() + if not isinstance(v, ifcopenshell.entity_instance) + ] class Material(Facet): diff --git a/src/ifctester/test/test_facet.py b/src/ifctester/test/test_facet.py index 862dd934dc..d8e23a32a1 100644 --- a/src/ifctester/test/test_facet.py +++ b/src/ifctester/test/test_facet.py @@ -1076,6 +1076,29 @@ class TestProperty: facet = Property(propertySet="Foo_Bar", name="Foo", measure="IfcLabel") run("Reference properties are treated as objects and not supported", facet=facet, inst=element, expected=False) + element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcDoor") + pset = ifc.create_entity( + "IfcDoorPanelProperties", + GlobalId=ifcopenshell.guid.new(), + Name="Foo_Bar", + PanelOperation="SWINGING", + PanelPosition="LEFT", + ) + ifc.create_entity( + "IfcRelDefinesByProperties", + GlobalId=ifcopenshell.guid.new(), + RelatedObjects=[element], + RelatingPropertyDefinition=pset, + ) + facet = Property( + propertySet="Foo_Bar", name="PanelOperation", value="SWINGING", measure="IfcDoorPanelOperationEnum" + ) + run("Predefined properties are supported but discouraged 1/2", facet=facet, inst=element, expected=True) + facet = Property( + propertySet="Foo_Bar", name="PanelOperation", value="SWONGING", measure="IfcDoorPanelOperationEnum" + ) + run("Predefined properties are supported but discouraged 2/2", facet=facet, inst=element, expected=False) + facet = Property(propertySet="Foo_Bar", name="Foo", measure="IfcLengthMeasure") element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall") qto = ifcopenshell.api.run("pset.add_qto", ifc, product=element, name="Foo_Bar")