From 89973a7a7667ca5c596c52d69427b1625a61a960 Mon Sep 17 00:00:00 2001 From: falken10vdl Date: Thu, 11 Dec 2025 01:22:34 +0100 Subject: [PATCH] Refactor to use blender properties so loading metadata preserves session settings --- src/bonsai/bonsai/bim/__init__.py | 41 +- src/bonsai/bonsai/bim/operator.py | 122 +++-- src/bonsai/bonsai/bim/prop.py | 13 + src/bonsai/bonsai/bim/ui.py | 754 ++++++++++++------------------ 4 files changed, 370 insertions(+), 560 deletions(-) diff --git a/src/bonsai/bonsai/bim/__init__.py b/src/bonsai/bonsai/bim/__init__.py index 23ecb2fea4..81dd85f72a 100644 --- a/src/bonsai/bonsai/bim/__init__.py +++ b/src/bonsai/bonsai/bim/__init__.py @@ -144,6 +144,7 @@ classes = [ prop.ISODuration, prop.BIMAreaProperties, prop.BIMTabProperties, + prop.BIMPanelProperties, # Must be registered before BIMProperties prop.BIMProperties, prop.IfcParameter, prop.PsetQto, @@ -238,42 +239,6 @@ def on_register(scene): is_registering = False -def register_panel_visibility_properties(): - for panel_list in ui.TAB_PANELS.values(): - for panel in panel_list: - bl_idname = panel.get("bl_idname", "") - prop_name = f"show_{bl_idname.lower()}" - setattr( - bpy.types.Scene, - prop_name, - bpy.props.BoolProperty( - name=f"Show {bl_idname}", - description=f"Show or hide the {bl_idname} panel", - default=True, - ), - ) - prop_name = f"bookmark_{bl_idname.lower()}" - setattr( - bpy.types.Scene, - prop_name, - bpy.props.BoolProperty( - name=f"Bookmark {bl_idname}", - description=f"Move to Bookmark or not {bl_idname} panel", - default=False, - ), - ) - - -def unregister_panel_visibility_properties(): - for panel_list in ui.TAB_PANELS.values(): - for panel in panel_list: - bl_idname = panel.get("bl_idname", "") - prop_name = f"show_{bl_idname.lower()}" - if hasattr(bpy.types.Scene, prop_name): - delattr(bpy.types.Scene, prop_name) - prop_name = f"bookmark_{bl_idname.lower()}" - if hasattr(bpy.types.Scene, prop_name): - delattr(bpy.types.Scene, prop_name) # Classes that need to be registered after modules (due to cross-module dependencies) @@ -319,6 +284,9 @@ def register(): bpy.types.Curve.BIMMeshProperties = bpy.props.PointerProperty(type=prop.BIMMeshProperties) bpy.types.Camera.BIMMeshProperties = bpy.props.PointerProperty(type=prop.BIMMeshProperties) bpy.types.PointLight.BIMMeshProperties = bpy.props.PointerProperty(type=prop.BIMMeshProperties) + + ui.initialize_panel_properties() + if hasattr(bpy.types, "UI_MT_button_context_menu"): bpy.types.UI_MT_button_context_menu.append(ui.draw_custom_context_menu) bpy.types.STATUSBAR_HT_header.append(ui.draw_statusbar) @@ -357,7 +325,6 @@ def register(): bpy.types.Scene.active_tab_name = bpy.props.StringProperty() bpy.types.Scene.tab_panels = bpy.props.CollectionProperty(type=bpy.types.PropertyGroup) bpy.types.Scene.active_tab_panel_index = bpy.props.IntProperty() - register_panel_visibility_properties() def unregister(): diff --git a/src/bonsai/bonsai/bim/operator.py b/src/bonsai/bonsai/bim/operator.py index aeff79283a..1a646ec0b3 100644 --- a/src/bonsai/bonsai/bim/operator.py +++ b/src/bonsai/bonsai/bim/operator.py @@ -33,7 +33,7 @@ import bonsai.bim import bonsai.tool as tool import bonsai.bim.handler from enum import Enum -from bonsai.bim.ui import TAB_PANELS, get_tab_visibility, set_tab_visibility, get_tab_names +from bonsai.bim.ui import get_all_tab_panels, get_tab_visibility, set_tab_visibility, get_tab_names, get_panel_config, initialize_panel_properties from bpy_extras.io_utils import ImportHelper from bonsai.bim import import_ifc from bonsai.bim.prop import StrProperty @@ -1725,24 +1725,29 @@ class BIM_OT_toggle_panel_visibility(bpy.types.Operator): def execute(self, context): panel_name = self.action.replace("TOGGLE_VISIBILITY_", "") - - for item in context.scene.tab_panels: - if item.name == panel_name: - item["visible"] = not item.get("visible", True) - - prop_name = f"show_{panel_name.lower()}" - if hasattr(context.scene, prop_name): - setattr(context.scene, prop_name, item["visible"]) - print(f"Toggled visibility for panel: {panel_name} to {'visible' if item['visible'] else 'hidden'}") - else: - print(f"Property '{prop_name}' not found on Scene.") - break - + active_tab = getattr(context.scene, "active_tab_name", None) or getattr(tool.Blender.get_bim_props(), "tab", None) + is_bookmark_tab = active_tab == "BOOKMARK" + + panel_config = get_panel_config(panel_name) + if panel_config: + if is_bookmark_tab: + panel_config.is_visible_in_bookmarks = not panel_config.is_visible_in_bookmarks + new_value = panel_config.is_visible_in_bookmarks + else: + panel_config.is_visible_in_tab = not panel_config.is_visible_in_tab + new_value = panel_config.is_visible_in_tab + + for item in context.scene.tab_panels: + if item.name == panel_name: + item["visible"] = new_value + break + for area in bpy.context.window.screen.areas: if area.type == "PROPERTIES": area.tag_redraw() - - self.report({"INFO"}, f"Toggled visibility for {panel_name}.") + + tab_context = "Bookmarks" if is_bookmark_tab else "Tab" + self.report({"INFO"}, f"Toggled visibility for {panel_name} in {tab_context}.") return {"FINISHED"} @@ -1757,40 +1762,20 @@ class BIM_OT_bookmark_panel(bpy.types.Operator): def execute(self, context): panel_name = self.action.replace("BOOKMARK_", "") - - for item in context.scene.tab_panels: - if item.name == panel_name: - item["bookmarked"] = not item.get("bookmarked", False) - - prop_name = f"bookmark_{panel_name.lower()}" - if hasattr(context.scene, prop_name): - setattr(context.scene, prop_name, item["bookmarked"]) - print( - f"Toggled bookmark for panel: {panel_name} to {'bookmarked' if item['bookmarked'] else 'Not bookmarked'}" - ) - else: - print(f"Property '{prop_name}' not found on Scene.") - - panel_label = item["bl_label"] - if item["bookmarked"]: - if not any(p.get("bl_idname") == panel_name for p in TAB_PANELS["BOOKMARK"]): - TAB_PANELS["BOOKMARK"].append({"bl_idname": panel_name, "bl_label": panel_label}) - print(f"Added {panel_name} to BOOKMARK tab.") - else: - for i, p in enumerate(TAB_PANELS["BOOKMARK"]): - if p.get("bl_idname") == panel_name: - del TAB_PANELS["BOOKMARK"][i] - print(f"Removed {panel_name} from BOOKMARK tab.") - if context.scene.active_tab_name == "BOOKMARK": - index = context.scene.tab_panels.find(panel_name) - if index != -1: - context.scene.tab_panels.remove(index) - break - + panel_config = get_panel_config(panel_name) + + if panel_config: + panel_config.is_bookmarked = not panel_config.is_bookmarked + + for item in context.scene.tab_panels: + if item.name == panel_name: + item["bookmarked"] = panel_config.is_bookmarked + break + for area in bpy.context.window.screen.areas: if area.type == "PROPERTIES": area.tag_redraw() - + self.report({"INFO"}, f"Toggled bookmark for {panel_name}.") return {"FINISHED"} @@ -1805,25 +1790,33 @@ class BIM_OT_manage_tab_panels(bpy.types.Operator): tab_name: bpy.props.StringProperty() def invoke(self, context, event): + context.scene.active_tab_name = self.tab_name - context.scene.tab_panels.clear() - for panel_data in TAB_PANELS.get(self.tab_name, []): + + initialize_panel_properties() + all_panels = get_all_tab_panels(force_refresh=True) + + for panel_data in all_panels.get(self.tab_name, []): panel_name = panel_data.get("bl_idname", "") panel_label = panel_data.get("bl_label", "") if not panel_name or not panel_label: continue + item = context.scene.tab_panels.add() item.name = panel_name item["bl_label"] = panel_label - show_prop_name = f"show_{panel_name.lower()}" - bookmark_prop_name = f"bookmark_{panel_name.lower()}" - - item["visible"] = getattr(context.scene, show_prop_name, True) - item["bookmarked"] = getattr(context.scene, bookmark_prop_name, False) - - print(f"Tab Panels for {self.tab_name}: {[item.name for item in context.scene.tab_panels]}") + panel_config = get_panel_config(panel_name) + if panel_config: + if self.tab_name == "BOOKMARK": + item["visible"] = panel_config.is_visible_in_bookmarks + else: + item["visible"] = panel_config.is_visible_in_tab + item["bookmarked"] = panel_config.is_bookmarked + else: + item["visible"] = True + item["bookmarked"] = False return context.window_manager.invoke_popup(self) @@ -1836,11 +1829,15 @@ class BIM_OT_manage_tab_panels(bpy.types.Operator): def execute(self, context): for item in context.scene.tab_panels: - show_prop_name = f"show_{item.name.lower()}" - bookmark_prop_name = f"bookmark_{item.name.lower()}" + panel_config = get_panel_config(item.name) + if panel_config: + if self.tab_name == "BOOKMARK": + panel_config.is_visible_in_bookmarks = item["visible"] + else: + panel_config.is_visible_in_tab = item["visible"] + panel_config.is_bookmarked = item["bookmarked"] + - setattr(context.scene, show_prop_name, item["visible"]) - setattr(context.scene, bookmark_prop_name, item["bookmarked"]) self.report({"INFO"}, f"Panels for {self.tab_name} managed successfully.") return {"FINISHED"} @@ -1912,14 +1909,13 @@ class BIM_OT_reset_ui_layout(bpy.types.Operator): bl_options = {"REGISTER", "UNDO"} def execute(self, context): - global TAB_PANELS for tab_name in get_tab_names(): set_tab_visibility(tab_name, True) - TAB_PANELS["BOOKMARK"] = [{}] + get_all_tab_panels()["BOOKMARK"] = [{}] - for tab_name, panels in TAB_PANELS.items(): + for tab_name, panels in get_all_tab_panels().items(): for panel in panels: panel_name = panel.get("bl_idname", "") if not panel_name: diff --git a/src/bonsai/bonsai/bim/prop.py b/src/bonsai/bonsai/bim/prop.py index 5409981181..7c501d6184 100644 --- a/src/bonsai/bonsai/bim/prop.py +++ b/src/bonsai/bonsai/bim/prop.py @@ -530,6 +530,17 @@ class BIMTabProperties(PropertyGroup): inactive_tab: bool +class BIMPanelProperties(PropertyGroup): + is_visible_in_tab: BoolProperty(name="Is Visible in Tab", default=True) + is_visible_in_bookmarks: BoolProperty(name="Is Visible in Bookmarks", default=True) + is_bookmarked: BoolProperty(name="Is Bookmarked", default=False) + + if TYPE_CHECKING: + is_visible_in_tab: bool + is_visible_in_bookmarks: bool + is_bookmarked: bool + + class BIMProperties(PropertyGroup): is_dirty: BoolProperty(name="Is Dirty", default=False) schema_dir: StringProperty( @@ -623,6 +634,7 @@ class BIMProperties(PropertyGroup): tab_visibility_fm: BoolProperty(name="FM Tab Visible", default=True) tab_visibility_quality: BoolProperty(name="Quality Tab Visible", default=True) tab_visibility_bookmark: BoolProperty(name="Bookmark Tab Visible", default=True) + panel_properties: CollectionProperty(type=BIMPanelProperties, name="Panel Properties") if TYPE_CHECKING: is_dirty: bool @@ -648,6 +660,7 @@ class BIMProperties(PropertyGroup): tab_visibility_fm: bool tab_visibility_quality: bool tab_visibility_bookmark: bool + panel_properties: bpy.types.bpy_prop_collection[BIMPanelProperties] class IfcParameter(PropertyGroup): diff --git a/src/bonsai/bonsai/bim/ui.py b/src/bonsai/bonsai/bim/ui.py index bed40c2b04..6589197f56 100644 --- a/src/bonsai/bonsai/bim/ui.py +++ b/src/bonsai/bonsai/bim/ui.py @@ -62,66 +62,101 @@ if TYPE_CHECKING: from bonsai.bim.module.project.prop import BIMProjectProperties -TAB_PANELS = { - "PROJECT": [ - # "BIM_PT_tab_new_project_wizard", - {"bl_idname": "BIM_PT_tab_project_info", "bl_label": "Project Info"}, - {"bl_idname": "BIM_PT_tab_spatial", "bl_label": "Spatial"}, - {"bl_idname": "BIM_PT_tab_project_setup", "bl_label": "Project Setup"}, - {"bl_idname": "BIM_PT_tab_geometry", "bl_label": "Geometry"}, - {"bl_idname": "BIM_PT_tab_stakeholders", "bl_label": "Stakeholders"}, - {"bl_idname": "BIM_PT_tab_grouping_and_filtering", "bl_label": "Grouping and Filtering"}, - ], - "OBJECT": [ - {"bl_idname": "BIM_PT_tab_object_metadata", "bl_label": "Object Metadata"}, - {"bl_idname": "BIM_PT_tab_misc", "bl_label": "Misc"}, - ], - "GEOMETRY": [ - {"bl_idname": "BIM_PT_tab_placement", "bl_label": "Placement"}, - {"bl_idname": "BIM_PT_tab_representations", "bl_label": "Representations"}, - {"bl_idname": "BIM_PT_tab_geometric_relationships", "bl_label": "Geometric Relationships"}, - {"bl_idname": "BIM_PT_tab_parametric_geometry", "bl_label": "Parametric Geometry"}, - {"bl_idname": "BIM_PT_tab_object_materials", "bl_label": "Object Materials"}, - {"bl_idname": "BIM_PT_tab_materials", "bl_label": "Materials"}, - {"bl_idname": "BIM_PT_tab_styles", "bl_label": "Styles"}, - {"bl_idname": "BIM_PT_tab_profiles", "bl_label": "Profiles"}, - ], - "DRAWINGS": [ - {"bl_idname": "BIM_PT_tab_sheets", "bl_label": "Sheets"}, - {"bl_idname": "BIM_PT_tab_drawings", "bl_label": "Drawings"}, - {"bl_idname": "BIM_PT_tab_schedules", "bl_label": "Schedules"}, - {"bl_idname": "BIM_PT_tab_references", "bl_label": "References"}, - ], - "SERVICES": [ - {"bl_idname": "BIM_PT_tab_services", "bl_label": "Services"}, - {"bl_idname": "BIM_PT_tab_zones", "bl_label": "Zones"}, - {"bl_idname": "BIM_PT_tab_solar_analysis", "bl_label": "Solar Analysis"}, - {"bl_idname": "BIM_PT_tab_lighting", "bl_label": "Lighting"}, - ], - "STRUCTURE": [ - {"bl_idname": "BIM_PT_tab_structural", "bl_label": "Structural"}, - ], - "SCHEDULING": [ - {"bl_idname": "BIM_PT_tab_status", "bl_label": "Status"}, - {"bl_idname": "BIM_PT_tab_qto", "bl_label": "Quantity Take-off"}, - {"bl_idname": "BIM_PT_tab_resources", "bl_label": "Resources"}, - {"bl_idname": "BIM_PT_tab_cost", "bl_label": "Cost"}, - {"bl_idname": "BIM_PT_tab_sequence", "bl_label": "Construction Scheduling"}, - ], - "FM": [ - {"bl_idname": "BIM_PT_tab_handover", "bl_label": "Handover"}, - {"bl_idname": "BIM_PT_tab_operations", "bl_label": "Operations"}, - ], - "QUALITY": [ - {"bl_idname": "BIM_PT_tab_quality_control", "bl_label": "Quality Control"}, - {"bl_idname": "BIM_PT_tab_clash_detection", "bl_label": "Clash Detection"}, - {"bl_idname": "BIM_PT_tab_collaboration", "bl_label": "Collaboration"}, - {"bl_idname": "BIM_PT_tab_sandbox", "bl_label": "Sandbox"}, - ], - "BOOKMARK": [ - {}, - ], -} +TAB_NAMES = ["PROJECT", "OBJECT", "GEOMETRY", "DRAWINGS", "SERVICES", "STRUCTURE", "SCHEDULING", "FM", "QUALITY", "BOOKMARK"] + +def get_tab_names(): + return TAB_NAMES + +def get_panel_tab_name(panel_class): + if hasattr(panel_class, 'bim_tab_name'): + return panel_class.bim_tab_name + return "PROJECT" # Default fallback + + +def should_show_panel(panel_id, panel_tab_name, context): + if tool.Blender.is_tab(context, "BOOKMARK"): + return is_panel_bookmarked(panel_id) and get_panel_visibility(panel_id, "BOOKMARK") + + if tool.Blender.is_tab(context, panel_tab_name): + return get_tab_visibility(panel_tab_name) and get_panel_visibility(panel_id, panel_tab_name) + + return False + +def initialize_panel_properties(): + try: + bim_props = tool.Blender.get_bim_props() + + if len(bim_props.panel_properties) > 0: + return + + for attr_name in dir(bpy.types): + if attr_name.startswith("BIM_PT_tab_"): + try: + panel_class = getattr(bpy.types, attr_name) + if not hasattr(panel_class, 'bl_idname'): + continue + + panel_id = panel_class.bl_idname + + prop = bim_props.panel_properties.add() + prop.name = panel_id + prop.is_visible_in_tab = True + prop.is_visible_in_bookmarks = True + prop.is_bookmarked = False + except: + pass + except: + pass + +def get_panel_config(panel_id): + try: + bim_props = tool.Blender.get_bim_props() + + for prop in bim_props.panel_properties: + if prop.name == panel_id: + return prop + + prop = bim_props.panel_properties.add() + prop.name = panel_id + prop.is_visible_in_tab = True + prop.is_visible_in_bookmarks = True + prop.is_bookmarked = False + return prop + except: + return None + +def get_all_tab_panels(force_refresh=False): + panels = {tab_name: [] for tab_name in get_tab_names() if tab_name != "BOOKMARK"} + panels["BOOKMARK"] = [] + + try: + bim_props = tool.Blender.get_bim_props() + for prop in bim_props.panel_properties: + try: + panel_class = getattr(bpy.types, prop.name, None) + if panel_class: + tab_name = get_panel_tab_name(panel_class) + if tab_name and tab_name != "BOOKMARK": + bl_label = getattr(panel_class, "bl_label", prop.name) + panels[tab_name].append({"bl_idname": prop.name, "bl_label": bl_label}) + except: + pass + + if prop.is_bookmarked: + try: + panel_class = getattr(bpy.types, prop.name, None) + if panel_class: + bl_label = getattr(panel_class, "bl_label", prop.name) + panels["BOOKMARK"].append({"bl_idname": prop.name, "bl_label": bl_label}) + except: + pass + except: + pass + + if not panels["BOOKMARK"]: + panels["BOOKMARK"] = [{}] + + return panels def get_tab_visibility(tab_name): @@ -133,31 +168,29 @@ def get_tab_visibility(tab_name): def set_tab_visibility(tab_name, visible): bim_props = tool.Blender.get_bim_props() prop_name = f"tab_visibility_{tab_name.lower()}" - if hasattr(bim_props, prop_name): - setattr(bim_props, prop_name, visible) + setattr(bim_props, prop_name, visible) -def get_tab_names(): - return list(TAB_PANELS.keys()) +def get_panel_visibility(panel_id, current_tab=None): + try: + panel_config = get_panel_config(panel_id) + if panel_config: + if current_tab == "BOOKMARK": + return panel_config.is_visible_in_bookmarks + else: + return panel_config.is_visible_in_tab + except: + pass + return True - -def get_tab_name(bl_idname): - return next( - (k for k, v in reversed(list(TAB_PANELS.items())) if k != "BOOKMARK" and any(d.get("bl_idname") == bl_idname for d in v)), - "BOOKMARK", - ) - - -def get_bl_label(bl_idname): - return next( - ( - panel["bl_label"] - for panels in TAB_PANELS.values() - for panel in panels - if isinstance(panel, dict) and panel.get("bl_idname") == bl_idname - ), - "NO LABEL", - ) +def is_panel_bookmarked(panel_id): + try: + panel_config = get_panel_config(panel_id) + if panel_config: + return panel_config.is_bookmarked + except: + pass + return False class IFCFileSelector: @@ -1181,12 +1214,13 @@ class BIM_PT_tab_new_project_wizard(Panel): bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" + bim_tab_name = "PROJECT" @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_new_project_wizard", True): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not tool.Blender.is_tab(context, "PROJECT"): + if not tool.Blender.is_tab(context, cls.bim_tab_name): return False bim_props = tool.Blender.get_bim_props() pprops = tool.Project.get_project_props() @@ -1202,29 +1236,24 @@ class BIM_PT_tab_new_project_wizard(Panel): class BIM_PT_tab_project_info(Panel): bl_idname = "BIM_PT_tab_project_info" - bl_label = get_bl_label(bl_idname) + bl_label = "Project Info" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" + bim_tab_name = "PROJECT" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)): + if tool.Blender.is_tab(context, cls.bim_tab_name): bim_props = tool.Blender.get_bim_props() pprops = tool.Project.get_project_props() if pprops.is_loading: return True elif tool.Ifc.get() or bim_props.ifc_file: return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): layout = self.layout @@ -1233,24 +1262,19 @@ class BIM_PT_tab_project_info(Panel): class BIM_PT_tab_spatial(Panel): bl_idname = "BIM_PT_tab_spatial" - bl_label = get_bl_label(bl_idname) + bl_label = "Spatial" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" + bim_tab_name = "PROJECT" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) and tool.Ifc.get(): + if tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get(): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1258,24 +1282,19 @@ class BIM_PT_tab_spatial(Panel): class BIM_PT_tab_project_setup(Panel): bl_idname = "BIM_PT_tab_project_setup" - bl_label = get_bl_label(bl_idname) + bl_label = "Project Setup" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" + bim_tab_name = "PROJECT" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)): + if tool.Blender.is_tab(context, cls.bim_tab_name): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1283,25 +1302,20 @@ class BIM_PT_tab_project_setup(Panel): class BIM_PT_tab_stakeholders(Panel): bl_idname = "BIM_PT_tab_stakeholders" - bl_label = get_bl_label(bl_idname) + bl_label = "Stakeholders" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" bl_options = {"DEFAULT_CLOSED"} + bim_tab_name = "PROJECT" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) and tool.Ifc.get(): + if tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get(): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1309,24 +1323,19 @@ class BIM_PT_tab_stakeholders(Panel): class BIM_PT_tab_collaboration(Panel): bl_idname = "BIM_PT_tab_collaboration" - bl_label = get_bl_label(bl_idname) + bl_label = "Collaboration" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" + bim_tab_name = "QUALITY" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)): + if tool.Blender.is_tab(context, cls.bim_tab_name): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1334,25 +1343,20 @@ class BIM_PT_tab_collaboration(Panel): class BIM_PT_tab_grouping_and_filtering(Panel): bl_idname = "BIM_PT_tab_grouping_and_filtering" - bl_label = get_bl_label(bl_idname) + bl_label = "Grouping and Filtering" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" bl_options = {"HEADER_LAYOUT_EXPAND"} + bim_tab_name = "PROJECT" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) and tool.Ifc.get(): + if tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get(): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1368,24 +1372,19 @@ class BIM_PT_tab_grouping_and_filtering(Panel): class BIM_PT_tab_geometry(Panel): bl_idname = "BIM_PT_tab_geometry" - bl_label = get_bl_label(bl_idname) + bl_label = "Geometry" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" + bim_tab_name = "PROJECT" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) and tool.Ifc.get(): + if tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get(): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1393,24 +1392,19 @@ class BIM_PT_tab_geometry(Panel): class BIM_PT_tab_status(Panel): bl_idname = "BIM_PT_tab_status" - bl_label = get_bl_label(bl_idname) + bl_label = "Status" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" + bim_tab_name = "SCHEDULING" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) and tool.Ifc.get(): + if tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get(): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1418,24 +1412,19 @@ class BIM_PT_tab_status(Panel): class BIM_PT_tab_qto(Panel): bl_idname = "BIM_PT_tab_qto" - bl_label = get_bl_label(bl_idname) + bl_label = "Quantity Take-off" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" + bim_tab_name = "SCHEDULING" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) and tool.Ifc.get(): + if tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get(): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1443,24 +1432,19 @@ class BIM_PT_tab_qto(Panel): class BIM_PT_tab_resources(Panel): bl_idname = "BIM_PT_tab_resources" - bl_label = get_bl_label(bl_idname) + bl_label = "Resources" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" + bim_tab_name = "SCHEDULING" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) and tool.Ifc.get(): + if tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get(): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1468,24 +1452,19 @@ class BIM_PT_tab_resources(Panel): class BIM_PT_tab_cost(Panel): bl_idname = "BIM_PT_tab_cost" - bl_label = get_bl_label(bl_idname) + bl_label = "Cost" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" + bim_tab_name = "SCHEDULING" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) and tool.Ifc.get(): + if tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get(): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1493,24 +1472,19 @@ class BIM_PT_tab_cost(Panel): class BIM_PT_tab_sequence(Panel): bl_idname = "BIM_PT_tab_sequence" - bl_label = get_bl_label(bl_idname) + bl_label = "Construction Scheduling" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" + bim_tab_name = "SCHEDULING" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) and tool.Ifc.get(): + if tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get(): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1518,24 +1492,19 @@ class BIM_PT_tab_sequence(Panel): class BIM_PT_tab_structural(Panel): bl_idname = "BIM_PT_tab_structural" - bl_label = get_bl_label(bl_idname) + bl_label = "Structural" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" + bim_tab_name = "STRUCTURE" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) and tool.Ifc.get(): + if tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get(): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1543,24 +1512,19 @@ class BIM_PT_tab_structural(Panel): class BIM_PT_tab_services(Panel): bl_idname = "BIM_PT_tab_services" - bl_label = get_bl_label(bl_idname) + bl_label = "Services" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" + bim_tab_name = "SERVICES" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) and tool.Ifc.get(): + if tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get(): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1568,24 +1532,19 @@ class BIM_PT_tab_services(Panel): class BIM_PT_tab_lighting(Panel): bl_idname = "BIM_PT_tab_lighting" - bl_label = get_bl_label(bl_idname) + bl_label = "Lighting" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" + bim_tab_name = "SERVICES" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) and tool.Ifc.get(): + if tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get(): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1593,24 +1552,19 @@ class BIM_PT_tab_lighting(Panel): class BIM_PT_tab_zones(Panel): bl_idname = "BIM_PT_tab_zones" - bl_label = get_bl_label(bl_idname) + bl_label = "Zones" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" + bim_tab_name = "SERVICES" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) and tool.Ifc.get(): + if tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get(): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1618,24 +1572,19 @@ class BIM_PT_tab_zones(Panel): class BIM_PT_tab_solar_analysis(Panel): bl_idname = "BIM_PT_tab_solar_analysis" - bl_label = get_bl_label(bl_idname) + bl_label = "Solar Analysis" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" + bim_tab_name = "SERVICES" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) and tool.Ifc.get(): + if tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get(): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1643,24 +1592,19 @@ class BIM_PT_tab_solar_analysis(Panel): class BIM_PT_tab_quality_control(Panel): bl_idname = "BIM_PT_tab_quality_control" - bl_label = get_bl_label(bl_idname) + bl_label = "Quality Control" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" + bim_tab_name = "QUALITY" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)): + if tool.Blender.is_tab(context, cls.bim_tab_name): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1668,24 +1612,19 @@ class BIM_PT_tab_quality_control(Panel): class BIM_PT_tab_clash_detection(Panel): bl_idname = "BIM_PT_tab_clash_detection" - bl_label = get_bl_label(bl_idname) + bl_label = "Clash Detection" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" + bim_tab_name = "QUALITY" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)): + if tool.Blender.is_tab(context, cls.bim_tab_name): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1693,25 +1632,20 @@ class BIM_PT_tab_clash_detection(Panel): class BIM_PT_tab_sandbox(Panel): bl_idname = "BIM_PT_tab_sandbox" - bl_label = get_bl_label(bl_idname) + bl_label = "Sandbox" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" bl_options = {"DEFAULT_CLOSED"} + bim_tab_name = "QUALITY" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)): + if tool.Blender.is_tab(context, cls.bim_tab_name): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): row = self.layout.row() @@ -1726,18 +1660,15 @@ class BIM_PT_tab_object_metadata(Panel): bl_region_type = "WINDOW" bl_context = "scene" bl_order = 1 + bim_tab_name = "OBJECT" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): - return False - if not getattr(context.scene, prop_visible, True): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False props = tool.Project.get_project_props() if ( - tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) + tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get() and (obj := context.active_object) # Hide links empty handles. @@ -1748,9 +1679,7 @@ class BIM_PT_tab_object_metadata(Panel): ) ): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1758,30 +1687,25 @@ class BIM_PT_tab_object_metadata(Panel): class BIM_PT_tab_placement(Panel): bl_idname = "BIM_PT_tab_placement" - bl_label = get_bl_label(bl_idname) + bl_label = "Placement" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" bl_order = 1 + bim_tab_name = "GEOMETRY" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): - return False - if not getattr(context.scene, prop_visible, True): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False if ( - tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) + tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get() and (obj := context.active_object) and tool.Ifc.get_entity(obj) ): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1789,29 +1713,18 @@ class BIM_PT_tab_placement(Panel): class BIM_PT_tab_representations(Panel): bl_idname = "BIM_PT_tab_representations" - bl_label = get_bl_label(bl_idname) + bl_label = "Representations" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" bl_order = 1 + bim_tab_name = "GEOMETRY" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if ( - tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) - and tool.Ifc.get() - and tool.Geometry.get_active_or_representation_obj() - ): - return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1819,26 +1732,21 @@ class BIM_PT_tab_representations(Panel): class BIM_PT_tab_geometric_relationships(Panel): bl_idname = "BIM_PT_tab_geometric_relationships" - bl_label = get_bl_label(bl_idname) + bl_label = "Geometric Relationships" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" bl_order = 1 bl_options = {"DEFAULT_CLOSED"} + bim_tab_name = "GEOMETRY" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) and tool.Ifc.get(): + if tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get(): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1846,31 +1754,19 @@ class BIM_PT_tab_geometric_relationships(Panel): class BIM_PT_tab_parametric_geometry(Panel): bl_idname = "BIM_PT_tab_parametric_geometry" - bl_label = get_bl_label(bl_idname) + bl_label = "Parametric Geometry" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" bl_order = 1 bl_options = {"DEFAULT_CLOSED"} + bim_tab_name = "GEOMETRY" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if ( - tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) - and tool.Ifc.get() - and (obj := context.active_object) - and tool.Ifc.get_entity(obj) - ): - return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1878,30 +1774,18 @@ class BIM_PT_tab_parametric_geometry(Panel): class BIM_PT_tab_object_materials(Panel): bl_idname = "BIM_PT_tab_object_materials" - bl_label = get_bl_label(bl_idname) + bl_label = "Object Materials" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" bl_order = 1 + bim_tab_name = "GEOMETRY" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if ( - tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) - and tool.Ifc.get() - and (obj := context.active_object) - and tool.Ifc.get_entity(obj) - ): - return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1909,25 +1793,20 @@ class BIM_PT_tab_object_materials(Panel): class BIM_PT_tab_materials(Panel): bl_idname = "BIM_PT_tab_materials" - bl_label = get_bl_label(bl_idname) + bl_label = "Materials" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" bl_order = 1 + bim_tab_name = "GEOMETRY" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) and tool.Ifc.get(): + if tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get(): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1935,25 +1814,20 @@ class BIM_PT_tab_materials(Panel): class BIM_PT_tab_styles(Panel): bl_idname = "BIM_PT_tab_styles" - bl_label = get_bl_label(bl_idname) + bl_label = "Styles" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" bl_order = 1 + bim_tab_name = "GEOMETRY" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) and tool.Ifc.get(): + if tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get(): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1961,25 +1835,20 @@ class BIM_PT_tab_styles(Panel): class BIM_PT_tab_profiles(Panel): bl_idname = "BIM_PT_tab_profiles" - bl_label = get_bl_label(bl_idname) + bl_label = "Profiles" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" bl_order = 1 + bim_tab_name = "GEOMETRY" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) and tool.Ifc.get(): + if tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get(): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -1987,25 +1856,20 @@ class BIM_PT_tab_profiles(Panel): class BIM_PT_tab_sheets(Panel): bl_idname = "BIM_PT_tab_sheets" - bl_label = get_bl_label(bl_idname) + bl_label = "Sheets" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" bl_order = 1 + bim_tab_name = "DRAWINGS" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) and tool.Ifc.get(): + if tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get(): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -2013,25 +1877,20 @@ class BIM_PT_tab_sheets(Panel): class BIM_PT_tab_drawings(Panel): bl_idname = "BIM_PT_tab_drawings" - bl_label = get_bl_label(bl_idname) + bl_label = "Drawings" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" bl_order = 1 + bim_tab_name = "DRAWINGS" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) and tool.Ifc.get(): + if tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get(): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -2039,25 +1898,20 @@ class BIM_PT_tab_drawings(Panel): class BIM_PT_tab_schedules(Panel): bl_idname = "BIM_PT_tab_schedules" - bl_label = get_bl_label(bl_idname) + bl_label = "Schedules" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" bl_order = 1 + bim_tab_name = "DRAWINGS" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) and tool.Ifc.get(): + if tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get(): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -2065,25 +1919,20 @@ class BIM_PT_tab_schedules(Panel): class BIM_PT_tab_references(Panel): bl_idname = "BIM_PT_tab_references" - bl_label = get_bl_label(bl_idname) + bl_label = "References" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" bl_order = 1 + bim_tab_name = "DRAWINGS" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) and tool.Ifc.get(): + if tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get(): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -2091,26 +1940,21 @@ class BIM_PT_tab_references(Panel): class BIM_PT_tab_misc(Panel): bl_idname = "BIM_PT_tab_misc" - bl_label = get_bl_label(bl_idname) + bl_label = "Misc" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" bl_order = 1 bl_options = {"DEFAULT_CLOSED"} + bim_tab_name = "OBJECT" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)) and tool.Ifc.get(): + if tool.Blender.is_tab(context, cls.bim_tab_name) and tool.Ifc.get(): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -2118,25 +1962,20 @@ class BIM_PT_tab_misc(Panel): class BIM_PT_tab_handover(Panel): bl_idname = "BIM_PT_tab_handover" - bl_label = get_bl_label(bl_idname) + bl_label = "Handover" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" bl_order = 1 + bim_tab_name = "FM" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)): + if tool.Blender.is_tab(context, cls.bim_tab_name): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass @@ -2144,25 +1983,20 @@ class BIM_PT_tab_handover(Panel): class BIM_PT_tab_operations(Panel): bl_idname = "BIM_PT_tab_operations" - bl_label = get_bl_label(bl_idname) + bl_label = "Operations" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "scene" bl_order = 2 + bim_tab_name = "FM" @classmethod def poll(cls, context): - prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" - prop_visible = f"show_{cls.bl_idname.lower()}" - if not get_tab_visibility(get_tab_name(cls.bl_idname)): + if not should_show_panel(cls.bl_idname, cls.bim_tab_name, context): return False - if not getattr(context.scene, prop_visible, True): - return False - if tool.Blender.is_tab(context, get_tab_name(cls.bl_idname)): + if tool.Blender.is_tab(context, cls.bim_tab_name): return True - if tool.Blender.is_tab(context, "BOOKMARK") and getattr(context.scene, prop_bookmark, False): - return True - return False + return tool.Blender.is_tab(context, "BOOKMARK") def draw(self, context): pass