From 86d0139f41b614c1490db79e36a669a7c1c19723 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 28 Oct 2024 16:23:22 +0500 Subject: [PATCH] Hide object related panels when there is no object active --- src/bonsai/bonsai/bim/ui.py | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/src/bonsai/bonsai/bim/ui.py b/src/bonsai/bonsai/bim/ui.py index e25c9e2a69..510fed80bc 100644 --- a/src/bonsai/bonsai/bim/ui.py +++ b/src/bonsai/bonsai/bim/ui.py @@ -837,7 +837,12 @@ class BIM_PT_tab_object_metadata(Panel): @classmethod def poll(cls, context): - return tool.Blender.is_tab(context, "OBJECT") and tool.Ifc.get() + return ( + tool.Blender.is_tab(context, "OBJECT") + and tool.Ifc.get() + and (obj := context.active_object) + and tool.Ifc.get_entity(obj) + ) def draw(self, context): pass @@ -852,7 +857,12 @@ class BIM_PT_tab_placement(Panel): @classmethod def poll(cls, context): - return tool.Blender.is_tab(context, "GEOMETRY") and tool.Ifc.get() + return ( + tool.Blender.is_tab(context, "GEOMETRY") + and tool.Ifc.get() + and (obj := context.active_object) + and tool.Ifc.get_entity(obj) + ) def draw(self, context): pass @@ -867,7 +877,12 @@ class BIM_PT_tab_representations(Panel): @classmethod def poll(cls, context): - return tool.Blender.is_tab(context, "GEOMETRY") and tool.Ifc.get() + return ( + tool.Blender.is_tab(context, "GEOMETRY") + and tool.Ifc.get() + and (obj := context.active_object) + and tool.Ifc.get_entity(obj) + ) def draw(self, context): pass @@ -899,7 +914,12 @@ class BIM_PT_tab_parametric_geometry(Panel): @classmethod def poll(cls, context): - return tool.Blender.is_tab(context, "GEOMETRY") and tool.Ifc.get() + return ( + tool.Blender.is_tab(context, "GEOMETRY") + and tool.Ifc.get() + and (obj := context.active_object) + and tool.Ifc.get_entity(obj) + ) def draw(self, context): pass @@ -914,7 +934,12 @@ class BIM_PT_tab_object_materials(Panel): @classmethod def poll(cls, context): - return tool.Blender.is_tab(context, "GEOMETRY") and tool.Ifc.get() + return ( + tool.Blender.is_tab(context, "GEOMETRY") + and tool.Ifc.get() + and (obj := context.active_object) + and tool.Ifc.get_entity(obj) + ) def draw(self, context): pass