mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Be more accommodating when fetching properties to allow for incomplete scripts.
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user