From af81aa1fae85b6dfbeb31aec6c55aa32ba53b9b9 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Wed, 14 May 2025 19:20:56 +0500 Subject: [PATCH] Reapply 06f1477 to fix not appearing IFC Description button Not that skipping non-string properties was a bad idea, but inserting it right at the beginning was - non-string IFC properties were missing IFC descriptions because of it. Moved it past `Attribute` check to avoid this issue. For anyone hearing about this feature for the first time - https://imgur.com/a/dNRao3R I assume this was also the issue that was encountered in #5892 --- src/bonsai/bonsai/bim/ui.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/bonsai/bonsai/bim/ui.py b/src/bonsai/bonsai/bim/ui.py index 5a8db1ca6f..18c07af033 100644 --- a/src/bonsai/bonsai/bim/ui.py +++ b/src/bonsai/bonsai/bim/ui.py @@ -1209,8 +1209,10 @@ def draw_custom_context_menu(self: bpy.types.Menu, context: bpy.types.Context) - prop: bpy.types.Property = context.button_prop prop_name = prop.identifier # TODO: when `prop_struct` doesn't have `prop_name`? - prop_value = getattr(prop_struct, prop_name, None) - if not isinstance(prop_value, str): + if not hasattr(prop_struct, prop_name): + return + prop_value = getattr(prop_struct, prop_name, ...) + if prop_value is ...: return version = tool.Ifc.get_schema() assert self.layout @@ -1240,6 +1242,13 @@ def draw_custom_context_menu(self: bpy.types.Menu, context: bpy.types.Context) - op = layout.operator("bim.copy_text_to_clipboard", text="Copy Attribute Name", icon="COPYDOWN") op.text = attr_name else: + # Basically context menu for any Blender property will end up here, + # and will check 3 types of docs. + # So at least we're skipping all non-string properties. + if not isinstance(prop_value, str): + return + + docs = None # Ugly but we can't know which type of data is under the cursor so we test everything until it clicks try: docs = get_entity_doc(version, prop_value)