Skip to content

Commit a3efa7e

Browse files
committed
util.element - fix IfcComplexProperty KeyError when verbose=True (#7921)
Introduced by me in b77df18
1 parent 4896946 commit a3efa7e

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/ifcopenshell-python/ifcopenshell/util/element.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ def get_properties(
469469
del data["HasProperties"]
470470
results[prop_name] = data
471471
if verbose:
472-
results[prop_name] = {"id": data["id"], "class": data["class"], "value": results[prop_name]}
472+
results[prop_name] = {"id": data["id"], "class": data["type"], "value": results[prop_name]}
473473
return results
474474

475475

src/ifcopenshell-python/test/util/test_element.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,35 @@ def test_getting_complex_properties_from_a_list_of_properties(self):
307307
}
308308
}
309309

310+
def test_getting_complex_properties_verbose(self):
311+
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
312+
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="pset")
313+
complex_property = self.file.create_entity("IfcComplexProperty", Name="prop", UsageName="usage_name")
314+
ifcopenshell.api.pset.edit_pset(self.file, pset=complex_property, properties={"a": "b"})
315+
pset.HasProperties = [complex_property]
316+
properties = subject.get_properties(pset.HasProperties, verbose=True)
317+
prop_value = properties["prop"]["value"]
318+
nested_prop = prop_value["properties"]["a"]
319+
assert properties == {
320+
"prop": {
321+
"id": complex_property.id(),
322+
"class": "IfcComplexProperty",
323+
"value": {
324+
"UsageName": "usage_name",
325+
"id": complex_property.id(),
326+
"type": "IfcComplexProperty",
327+
"properties": {
328+
"a": {
329+
"id": nested_prop["id"],
330+
"class": "IfcPropertySingleValue",
331+
"value": "b",
332+
"value_type": "IfcLabel",
333+
}
334+
},
335+
},
336+
}
337+
}
338+
310339

311340
class TestGetElementsUsingPset(test.bootstrap.IFC4):
312341
def test_run(self):

0 commit comments

Comments
 (0)