sort representation items in ui based on shape aspect

- display shape aspect along with the repsentation type
- sort representation items based on shape aspects name, items without shape aspects come last
This commit is contained in:
Andrej730
2024-02-15 16:04:01 +05:00
parent ae47de8851
commit 8b360742a7
2 changed files with 9 additions and 1 deletions
@@ -1603,6 +1603,11 @@ class EnableEditingRepresentationItems(bpy.types.Operator, Operator):
new.shape_aspect = shape_aspect.Name
new.shape_aspect_id = shape_aspect.id()
# sort created items
sorted_items = sorted(props.items[:], key=lambda i: (not i.shape_aspect, i.shape_aspect))
for i, item in enumerate(sorted_items[:-1]): # last item is sorted automatically
props.items.move(props.items[:].index(item), i)
class DisableEditingRepresentationItems(bpy.types.Operator, Operator):
bl_idname = "bim.disable_editing_representation_items"
@@ -507,7 +507,10 @@ class BIM_UL_representation_items(UIList):
if item:
icon = "MATERIAL" if item.surface_style else "MESH_UVSPHERE"
row = layout.row(align=True)
row.label(text=item.name, icon=icon)
item_name = item.name
if item.shape_aspect:
item_name = f"{item.shape_aspect} {item_name}"
row.label(text=item_name, icon=icon)
if item.layer:
row.label(text="", icon="STICKY_UVS_LOC")
op = row.operator("bim.remove_representation_item", icon="X", text="")