mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Fix #4649. Bug where editing property set template enumerations didn't clean up properly.
This commit is contained in:
@@ -47,7 +47,20 @@ def edit_prop_template(
|
||||
ifcopenshell.api.run("pset_template.edit_prop_template", model,
|
||||
prop_template=prop, attributes={"Name": "DemoA", "PrimaryMeasureType": "IfcLengthMeasure"})
|
||||
"""
|
||||
settings = {"prop_template": prop_template, "attributes": attributes}
|
||||
if enum_values := attributes.get("Enumerators", None):
|
||||
prop_name = attributes.get("Name", None) or getattr(prop_template, "Name", None) or "Unnamed"
|
||||
primary_measure_type = (
|
||||
attributes.get("PrimaryMeasureType", None) or getattr(prop_template, "PrimaryMeasureType", None) or "IfcLabel"
|
||||
)
|
||||
enum_values = [file.create_entity(primary_measure_type, v) for v in enum_values]
|
||||
if enumerators := prop_template.Enumerators:
|
||||
enumerators.Name = prop_name
|
||||
enumerators.EnumerationValues = enum_values
|
||||
else:
|
||||
prop_template.Enumerators = file.create_entity("IfcPropertyEnumeration", prop_name, enum_values)
|
||||
|
||||
for name, value in settings["attributes"].items():
|
||||
setattr(settings["prop_template"], name, value)
|
||||
if "Enumerators" in attributes:
|
||||
del attributes["Enumerators"]
|
||||
|
||||
for name, value in attributes.items():
|
||||
setattr(prop_template, name, value)
|
||||
|
||||
Reference in New Issue
Block a user