Sort pset names and properties alphabetically

Can't believe it took this long to get around to doing this
This commit is contained in:
Dion Moult
2024-07-29 10:43:15 +10:00
parent f60c4fd3c5
commit 74141bec73
2 changed files with 4 additions and 4 deletions
@@ -51,13 +51,13 @@ class Data:
psetqtos = ifcopenshell.util.element.get_psets(
element, psets_only=psets_only, qtos_only=qtos_only, should_inherit=False
)
for name, data in psetqtos.items():
for name, data in sorted(psetqtos.items()):
results.append(
{
"id": data["id"],
"Name": name,
"is_expanded": is_expanded.get(data["id"], True),
"Properties": [{"Name": k, "NominalValue": v} for k, v in data.items() if k != "id"],
"Properties": [{"Name": k, "NominalValue": v} for k, v in sorted(data.items()) if k != "id"],
}
)
return sorted(results, key=lambda v: v["Name"])
+2 -2
View File
@@ -98,7 +98,7 @@ class Pset(blenderbim.core.tool.Pset):
elif pset.is_a("IfcMaterialProperties") or pset.is_a("IfcProfileProperties"):
pset_props = pset.Properties
for prop in pset_props:
for prop in sorted(pset_props, key=lambda p: p.Name):
if props.properties.get(prop.Name):
continue # This property has already been added from a template
if prop.is_a("IfcPropertyEnumeratedValue"):
@@ -213,7 +213,7 @@ class Pset(blenderbim.core.tool.Pset):
del data["id"]
else:
data = {}
for prop_template in pset_template.HasPropertyTemplates:
for prop_template in sorted(pset_template.HasPropertyTemplates, key=lambda p: p.Name):
if not prop_template.is_a("IfcSimplePropertyTemplate"):
continue # Other types not yet supported
if prop_template.TemplateType == "P_SINGLEVALUE":