Be more accommodating when fetching properties to allow for incomplete scripts.

This commit is contained in:
Dion Moult
2021-09-20 14:45:31 +10:00
parent 70ba681b35
commit 92e519de9e
2 changed files with 6 additions and 1 deletions
@@ -41,7 +41,7 @@ def get_quantities(quantities):
def get_properties(properties):
results = {}
for prop in properties:
for prop in properties or []:
if prop.is_a("IfcPropertySingleValue"):
results[prop.Name] = prop.NominalValue.wrappedValue if prop.NominalValue else None
elif prop.is_a("IfcComplexProperty"):
@@ -51,6 +51,11 @@ class TestGetQuantitiesIFC4(test.bootstrap.IFC4):
class TestGetPropertiesIFC4(test.bootstrap.IFC4):
def test_getting_no_properties_when_none_are_available(self):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="name")
assert ifcopenshell.util.element.get_properties(pset.HasProperties) == {}
def test_getting_single_properties_from_a_list_of_properties(self):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="name")