From 233ad63bca01caafcfffa4fa3f381ad05505872a Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Fri, 16 Jan 2026 20:11:43 +1100 Subject: [PATCH] Remove document menu for UI consistency Although it is a very cool trick, I feel this essentially duplicates the UI in two spots, and is an outlier in UX. I'd prefer for all IFC data and relationships to be in one location only (the panels). I think there are a better unified solutions (e.g. favourite bookmark panels) for quick access for things like this. --- .../bonsai/bim/module/document/__init__.py | 3 - src/bonsai/bonsai/bim/module/document/ui.py | 65 ------------------- 2 files changed, 68 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/document/__init__.py b/src/bonsai/bonsai/bim/module/document/__init__.py index cc71d16306..3881148a18 100644 --- a/src/bonsai/bonsai/bim/module/document/__init__.py +++ b/src/bonsai/bonsai/bim/module/document/__init__.py @@ -42,15 +42,12 @@ classes = ( ui.BIM_PT_object_documents, ui.BIM_UL_documents, ui.BIM_UL_document_objects, - ui.BIM_MT_object_documents_context_menu, ) def register(): bpy.types.Scene.BIMDocumentProperties = bpy.props.PointerProperty(type=prop.BIMDocumentProperties) - bpy.types.VIEW3D_MT_object_context_menu.append(ui.add_object_documents_context_menu) def unregister(): del bpy.types.Scene.BIMDocumentProperties - bpy.types.VIEW3D_MT_object_context_menu.remove(ui.add_object_documents_context_menu) diff --git a/src/bonsai/bonsai/bim/module/document/ui.py b/src/bonsai/bonsai/bim/module/document/ui.py index c382f1c721..7688399732 100644 --- a/src/bonsai/bonsai/bim/module/document/ui.py +++ b/src/bonsai/bonsai/bim/module/document/ui.py @@ -265,68 +265,3 @@ class BIM_UL_document_objects(UIList): op = row.operator("bim.unassign_document", text="", icon="X") op.document = document.ifc_definition_id op.obj = item.name - - -def add_object_documents_context_menu(self, context): - if not context.active_object: - return - - if not tool.Blender.get_ifc_definition_id(context.active_object): - return - - self.layout.separator() - self.layout.menu("BIM_MT_object_documents_context_menu", icon="FILE") - - -class BIM_MT_object_documents_context_menu(bpy.types.Menu): - bl_idname = "BIM_MT_object_documents_context_menu" - bl_label = "Documents" - - def draw(self, context): - layout = self.layout - - if not context.selected_objects: - layout.label(text="No documents", icon="INFO") - return - - if len(context.selected_objects) > 1: - layout.label(text="Select a single object to see its referenced documents", icon="INFO") - return - - obj = context.active_object - if not obj or not tool.Blender.get_ifc_definition_id(obj): - layout.label(text="No documents", icon="INFO") - return - - if not ObjectDocumentData.is_loaded: - ObjectDocumentData.load() - - if not ObjectDocumentData.data["documents"]: - layout.label(text="No Documents", icon="FILE") - else: - for document in ObjectDocumentData.data["documents"]: - row = layout.row(align=True) - - with_ifc_icon = document["location"] and document["location"].lower().endswith(".ifc") - with_url_icon = bool(document["location"]) - - if with_ifc_icon: - row.operator("bim.open_ifc_document", icon="HIDE_OFF", text="").uri = document["location"] - else: - row.label(text="", icon="BLANK1") - - if with_url_icon: - row.operator("bim.open_uri", icon="URL", text="").uri = document["location"] - else: - row.label(text="", icon="BLANK1") - - doc_entity = None - if "id" in document: - doc_entity = tool.Ifc.get().by_id(document["id"]) - - if doc_entity and doc_entity.is_a("IfcDocumentReference"): - display_text = document.get("description") or "" - else: - display_text = document.get("name") or "" - - row.label(text=f"{document['identification'] or ''}: {display_text}")