From 656e3bb4e81464320f2c9d828c2508e79f53d5c1 Mon Sep 17 00:00:00 2001 From: Ryan Schultz Date: Sat, 30 May 2026 21:53:13 -0500 Subject: [PATCH] Add select_similar to type attribute panels In BIM_PT_type_attributes and BIM_PT_object_attributes (when the active object is a type), attribute value buttons now use "type." as the selector key so the operator finds matching occurrences via their relating type rather than the occurrence's own (often unset) attributes. Generated with the assistance of an AI coding tool. --- src/bonsai/bonsai/bim/module/attribute/ui.py | 4 +++- src/bonsai/bonsai/bim/module/type/ui.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/attribute/ui.py b/src/bonsai/bonsai/bim/module/attribute/ui.py index 84813e8d1e..934b053d2e 100644 --- a/src/bonsai/bonsai/bim/module/attribute/ui.py +++ b/src/bonsai/bonsai/bim/module/attribute/ui.py @@ -48,12 +48,14 @@ def draw_ui(context: bpy.types.Context, layout: bpy.types.UILayout, attributes) row = layout.row() op = row.operator("bim.enable_editing_attributes", icon="GREASEPENCIL", text="Edit") + element = tool.Ifc.get_entity(obj) + key_prefix = "type." if (element and element.is_a("IfcTypeObject")) else "" for attribute in attributes: row = layout.row(align=True) row.label(text=attribute["name"]) value = bonsai.bim.helper.get_display_value(attribute["value"]) op = row.operator("bim.select_similar", text=value, icon="NONE", emboss=False) - op.key = attribute["name"] + op.key = key_prefix + attribute["name"] # TODO: reimplement, see #1222 # if "IfcSite/" in context.active_object.name or "IfcBuilding/" in context.active_object.name: diff --git a/src/bonsai/bonsai/bim/module/type/ui.py b/src/bonsai/bonsai/bim/module/type/ui.py index fbd1edd446..1848858953 100644 --- a/src/bonsai/bonsai/bim/module/type/ui.py +++ b/src/bonsai/bonsai/bim/module/type/ui.py @@ -151,7 +151,8 @@ class BIM_PT_type_attributes(Panel): row = layout.row(align=True) row.label(text=attribute["name"]) value = get_display_value(attribute["value"]) - row.label(text=value) + op = row.operator("bim.select_similar", text=value, icon="NONE", emboss=False) + op.key = "type." + attribute["name"] def add_object_button(self, context):