mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
Sort pset names and properties alphabetically
Can't believe it took this long to get around to doing this
This commit is contained in:
@@ -51,13 +51,13 @@ class Data:
|
|||||||
psetqtos = ifcopenshell.util.element.get_psets(
|
psetqtos = ifcopenshell.util.element.get_psets(
|
||||||
element, psets_only=psets_only, qtos_only=qtos_only, should_inherit=False
|
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(
|
results.append(
|
||||||
{
|
{
|
||||||
"id": data["id"],
|
"id": data["id"],
|
||||||
"Name": name,
|
"Name": name,
|
||||||
"is_expanded": is_expanded.get(data["id"], True),
|
"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"])
|
return sorted(results, key=lambda v: v["Name"])
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ class Pset(blenderbim.core.tool.Pset):
|
|||||||
elif pset.is_a("IfcMaterialProperties") or pset.is_a("IfcProfileProperties"):
|
elif pset.is_a("IfcMaterialProperties") or pset.is_a("IfcProfileProperties"):
|
||||||
pset_props = pset.Properties
|
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):
|
if props.properties.get(prop.Name):
|
||||||
continue # This property has already been added from a template
|
continue # This property has already been added from a template
|
||||||
if prop.is_a("IfcPropertyEnumeratedValue"):
|
if prop.is_a("IfcPropertyEnumeratedValue"):
|
||||||
@@ -213,7 +213,7 @@ class Pset(blenderbim.core.tool.Pset):
|
|||||||
del data["id"]
|
del data["id"]
|
||||||
else:
|
else:
|
||||||
data = {}
|
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"):
|
if not prop_template.is_a("IfcSimplePropertyTemplate"):
|
||||||
continue # Other types not yet supported
|
continue # Other types not yet supported
|
||||||
if prop_template.TemplateType == "P_SINGLEVALUE":
|
if prop_template.TemplateType == "P_SINGLEVALUE":
|
||||||
|
|||||||
Reference in New Issue
Block a user