Annotation types - use natural sorting, make 'Untyped' appear always on top

This commit is contained in:
Andrej730
2025-09-10 14:56:14 +05:00
parent e9bad17502
commit 7bea3d9d10
+4 -3
View File
@@ -25,6 +25,7 @@ import ifcopenshell.util.unit
import bonsai.tool as tool import bonsai.tool as tool
from pathlib import Path from pathlib import Path
from typing import Any, Union from typing import Any, Union
from natsort import natsorted
def refresh(): def refresh():
@@ -480,9 +481,9 @@ class AnnotationData:
if tool.Drawing.is_annotation_object_type(relating_type, object_type): if tool.Drawing.is_annotation_object_type(relating_type, object_type):
relating_types.append(relating_type) relating_types.append(relating_type)
results = [("0", "Untyped", "")] results = [(str(e.id()), e.Name or "Unnamed", e.Description or "") for e in relating_types]
results.extend([(str(e.id()), e.Name or "Unnamed", e.Description or "") for e in relating_types]) results = natsorted(results, key=lambda x: x[1])
results.sort(key=lambda x: x[1].lower()) results = [("0", "Untyped", "")] + results
return results return results
@classmethod @classmethod