From 73ac5d314b2aa65a48beda1f4d1c9e876d24ad35 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Mon, 12 Sep 2022 20:10:16 +1000 Subject: [PATCH] Complex properties and quantities are not supported in IDS --- .../ifcopenshell/api/pset/edit_qto.py | 10 ++++++--- src/ifctester/ifctester/facet.py | 7 ++++++ src/ifctester/test/test_facet.py | 22 +++++++++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/pset/edit_qto.py b/src/ifcopenshell-python/ifcopenshell/api/pset/edit_qto.py index 1abb97f1fa..832905fa4f 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/pset/edit_qto.py +++ b/src/ifcopenshell-python/ifcopenshell/api/pset/edit_qto.py @@ -28,6 +28,10 @@ class Usecase: self.settings[key] = value def execute(self): + self.qto_idx = 5 + if self.settings["qto"].is_a("IfcPhysicalComplexQuantity"): + self.qto_idx = 2 + self.update_qto_name() self.load_qto_template() self.update_existing_properties() @@ -44,7 +48,7 @@ class Usecase: self.qto_template = self.psetqto.get_by_name(self.settings["qto"].Name) def update_existing_properties(self): - for prop in self.settings["qto"].Quantities or []: + for prop in self.settings["qto"][self.qto_idx] or []: self.update_existing_property(prop) def update_existing_property(self, prop): @@ -75,9 +79,9 @@ class Usecase: return properties def extend_qto_with_new_properties(self, new_properties): - props = list(self.settings["qto"].Quantities) if self.settings["qto"].Quantities else [] + props = list(self.settings["qto"][self.qto_idx]) if self.settings["qto"][self.qto_idx] else [] props.extend(new_properties) - self.settings["qto"].Quantities = props + self.settings["qto"][self.qto_idx] = props def get_canonical_property_type(self, name, value): if isinstance(value, ifcopenshell.entity_instance): diff --git a/src/ifctester/ifctester/facet.py b/src/ifctester/ifctester/facet.py index 06f3d01442..a392fe36b9 100644 --- a/src/ifctester/ifctester/facet.py +++ b/src/ifctester/ifctester/facet.py @@ -460,10 +460,12 @@ class Property(Facet): pset_entity = inst.wrapped_data.file.by_id(pset_props["id"]) + is_property_supported_class = False for prop_entity in self.get_properties(pset_entity): if prop_entity.is_a("IfcPropertySingleValue"): if prop_entity.Name not in props[pset_name].keys() or prop_entity.NominalValue is None: continue + is_property_supported_class = True data_type = prop_entity.NominalValue.is_a() @@ -484,6 +486,7 @@ class Property(Facet): elif prop_entity.is_a("IfcPhysicalSimpleQuantity"): if prop_entity.Name not in props[pset_name].keys(): continue + is_property_supported_class = True prop_schema = prop_entity.wrapped_data.declaration().as_entity() data_type = prop_schema.attribute_by_index(3).type_of_attribute().declared_type().name() @@ -503,6 +506,10 @@ class Property(Facet): ifcopenshell.util.unit.si_type_names[unit.UnitType], ) + if not is_property_supported_class: + is_pass = False + reason = {"type": "NOVALUE"} + if not is_pass: break diff --git a/src/ifctester/test/test_facet.py b/src/ifctester/test/test_facet.py index d00cd5b7ca..424a1aaa5a 100644 --- a/src/ifctester/test/test_facet.py +++ b/src/ifctester/test/test_facet.py @@ -1017,6 +1017,28 @@ class TestProperty: facet = Property(propertySet="Foo_Bar", name="Foo", measure="IfcAreaMeasure") run("Quantities must also match the appropriate measure", facet=facet, inst=element, expected=False) + element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall") + pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar") + complex_property = ifc.createIfcComplexProperty(Name="Foo", UsageName="RabbitAgilityTraining") + ifcopenshell.api.run("pset.edit_pset", ifc, pset=complex_property, properties={"Rabbits": "Awesome"}) + pset.HasProperties = [complex_property] + facet = Property(propertySet="Foo_Bar", name="Foo", measure="IfcLabel") + run("Complex properties are not supported 1/2", facet=facet, inst=element, expected=False) + facet = Property(propertySet="Foo", name="Rabbits", measure="IfcLabel") + run("Complex properties are not supported 2/2", facet=facet, inst=element, expected=False) + + element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall") + qto = ifcopenshell.api.run("pset.add_qto", ifc, product=element, name="Foo_Bar") + complex_quantity = ifc.createIfcPhysicalComplexQuantity(Name="Foo", Discrimination="FurThickness") + ifcopenshell.api.run( + "pset.edit_qto", ifc, qto=complex_quantity, properties={"MyLength": ifc.createIfcLengthMeasure(42)} + ) + qto.Quantities = [complex_quantity] + facet = Property(propertySet="Foo_Bar", name="Foo", measure="IfcLengthMeasure") + run("Complex properties are not supported 1/2", facet=facet, inst=element, expected=False) + facet = Property(propertySet="Foo", name="MyLength", measure="IfcLengthMeasure") + run("Complex properties are not supported 2/2", facet=facet, inst=element, expected=False) + restriction = Restriction(options="Foo_.*", type="pattern") facet = Property(propertySet=restriction, name="Foo", measure="IfcLabel") element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")