From 2cac0bdca69a54d683b5fa443746ba99fd9d1533 Mon Sep 17 00:00:00 2001 From: falken10vdl Date: Sun, 21 Dec 2025 12:17:54 +0100 Subject: [PATCH] SaveBlendMetadataFile to use IFC directory for temporary file path and fix panel visibility logic in UI --- src/bonsai/bonsai/bim/operator.py | 5 +++-- src/bonsai/bonsai/bim/ui.py | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/bonsai/bonsai/bim/operator.py b/src/bonsai/bonsai/bim/operator.py index 82ac6ca185..a3f58d1c44 100644 --- a/src/bonsai/bonsai/bim/operator.py +++ b/src/bonsai/bonsai/bim/operator.py @@ -260,10 +260,11 @@ class SaveBlendMetadataFile(bpy.types.Operator): self.report({"WARNING"}, "No IFC file path set.") return {"CANCELLED"} + blendmetadata_path = ifc_file + ".metadata.blend" - # Save a temporary copy of the current blend file - temp_path = bpy.path.abspath("//__temp_blendmetadata.blend") + ifc_dir = os.path.dirname(ifc_file) + temp_path = os.path.join(ifc_dir, "__temp_blendmetadata.blend") bpy.ops.wm.save_as_mainfile(filepath=temp_path, copy=True) cleanup_script = f""" diff --git a/src/bonsai/bonsai/bim/ui.py b/src/bonsai/bonsai/bim/ui.py index 6c2baaa0fb..338c766b81 100644 --- a/src/bonsai/bonsai/bim/ui.py +++ b/src/bonsai/bonsai/bim/ui.py @@ -1633,6 +1633,8 @@ class BIM_PT_tab_representations(Panel): def poll(cls, context): if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False + if tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get(): + return True return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): @@ -1675,6 +1677,8 @@ class BIM_PT_tab_parametric_geometry(Panel): def poll(cls, context): if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False + if tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get(): + return True return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): @@ -1694,6 +1698,8 @@ class BIM_PT_tab_object_materials(Panel): def poll(cls, context): if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False + if tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get(): + return True return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context):