Complex properties and quantities are not supported in IDS

This commit is contained in:
Dion Moult
2022-09-12 20:10:16 +10:00
parent 3b2cbac9d1
commit 73ac5d314b
3 changed files with 36 additions and 3 deletions
@@ -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):
+7
View File
@@ -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
+22
View File
@@ -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")