diff --git a/src/blenderbim/blenderbim/bim/handler.py b/src/blenderbim/blenderbim/bim/handler.py index 79f925c6e2..2c6219c0c2 100644 --- a/src/blenderbim/blenderbim/bim/handler.py +++ b/src/blenderbim/blenderbim/bim/handler.py @@ -280,8 +280,8 @@ if getattr(bpy.types, "SCENE_PT_scene"): @classmethod def poll(cls, context): - aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)] - return aprops.tab == "BLENDER" + aprops = tool.Blender.get_area_properties(context) + return aprops.tab == "BLENDER" or context.area.spaces.active.search_filter if getattr(bpy.types, "SCENE_PT_unit"): @@ -291,8 +291,8 @@ if getattr(bpy.types, "SCENE_PT_unit"): @classmethod def poll(cls, context): - aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)] - return aprops.tab == "BLENDER" + aprops = tool.Blender.get_area_properties(context) + return aprops.tab == "BLENDER" or context.area.spaces.active.search_filter if getattr(bpy.types, "SCENE_PT_physics"): @@ -302,8 +302,8 @@ if getattr(bpy.types, "SCENE_PT_physics"): @classmethod def poll(cls, context): - aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)] - return aprops.tab == "BLENDER" + aprops = tool.Blender.get_area_properties(context) + return aprops.tab == "BLENDER" or context.area.spaces.active.search_filter if getattr(bpy.types, "SCENE_PT_rigid_body_world"): @@ -313,8 +313,8 @@ if getattr(bpy.types, "SCENE_PT_rigid_body_world"): @classmethod def poll(cls, context): - aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)] - return aprops.tab == "BLENDER" + aprops = tool.Blender.get_area_properties(context) + return aprops.tab == "BLENDER" or context.area.spaces.active.search_filter if getattr(bpy.types, "SCENE_PT_audio"): @@ -324,8 +324,8 @@ if getattr(bpy.types, "SCENE_PT_audio"): @classmethod def poll(cls, context): - aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)] - return aprops.tab == "BLENDER" + aprops = tool.Blender.get_area_properties(context) + return aprops.tab == "BLENDER" or context.area.spaces.active.search_filter if getattr(bpy.types, "SCENE_PT_keying_sets"): @@ -335,8 +335,8 @@ if getattr(bpy.types, "SCENE_PT_keying_sets"): @classmethod def poll(cls, context): - aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)] - return aprops.tab == "BLENDER" + aprops = tool.Blender.get_area_properties(context) + return aprops.tab == "BLENDER" or context.area.spaces.active.search_filter if getattr(bpy.types, "SCENE_PT_custom_props"): @@ -346,8 +346,8 @@ if getattr(bpy.types, "SCENE_PT_custom_props"): @classmethod def poll(cls, context): - aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)] - return aprops.tab == "BLENDER" + aprops = tool.Blender.get_area_properties(context) + return aprops.tab == "BLENDER" or context.area.spaces.active.search_filter @persistent diff --git a/src/blenderbim/blenderbim/bim/module/brick/ui.py b/src/blenderbim/blenderbim/bim/module/brick/ui.py index 594a7bef1c..c9dc3092f8 100644 --- a/src/blenderbim/blenderbim/bim/module/brick/ui.py +++ b/src/blenderbim/blenderbim/bim/module/brick/ui.py @@ -32,8 +32,8 @@ class BIM_PT_brickschema(Panel): @classmethod def poll(cls, context): - aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)] - return aprops.tab == "OTHER" + aprops = tool.Blender.get_area_properties(context) + return aprops.tab == "OTHER" or context.area.spaces.active.search_filter def draw(self, context): if not BrickschemaData.is_loaded: diff --git a/src/blenderbim/blenderbim/bim/module/drawing/ui.py b/src/blenderbim/blenderbim/bim/module/drawing/ui.py index 432d3c0daa..2312015be8 100644 --- a/src/blenderbim/blenderbim/bim/module/drawing/ui.py +++ b/src/blenderbim/blenderbim/bim/module/drawing/ui.py @@ -167,8 +167,8 @@ class BIM_PT_drawings(Panel): @classmethod def poll(cls, context): - aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)] - return aprops.tab == "DRAWINGS" and tool.Ifc.get() + aprops = tool.Blender.get_area_properties(context) + return (aprops.tab == "DRAWINGS" or context.area.spaces.active.search_filter) and tool.Ifc.get() def draw(self, context): if not DrawingsData.is_loaded: @@ -236,8 +236,8 @@ class BIM_PT_schedules(Panel): @classmethod def poll(cls, context): - aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)] - return aprops.tab == "DRAWINGS" and tool.Ifc.get() + aprops = tool.Blender.get_area_properties(context) + return (aprops.tab == "DRAWINGS" or context.area.spaces.active.search_filter) and tool.Ifc.get() def draw(self, context): if not DocumentsData.is_loaded: @@ -292,8 +292,8 @@ class BIM_PT_references(Panel): @classmethod def poll(cls, context): - aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)] - return aprops.tab == "DRAWINGS" and tool.Ifc.get() + aprops = tool.Blender.get_area_properties(context) + return (aprops.tab == "DRAWINGS" or context.area.spaces.active.search_filter) and tool.Ifc.get() def draw(self, context): if not DocumentsData.is_loaded: @@ -337,8 +337,8 @@ class BIM_PT_sheets(Panel): @classmethod def poll(cls, context): - aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)] - return aprops.tab == "DRAWINGS" and tool.Ifc.get() + aprops = tool.Blender.get_area_properties(context) + return (aprops.tab == "DRAWINGS" or context.area.spaces.active.search_filter) and tool.Ifc.get() def draw(self, context): if not SheetsData.is_loaded: diff --git a/src/blenderbim/blenderbim/bim/operator.py b/src/blenderbim/blenderbim/bim/operator.py index be707d2684..fb10036b9d 100644 --- a/src/blenderbim/blenderbim/bim/operator.py +++ b/src/blenderbim/blenderbim/bim/operator.py @@ -47,7 +47,7 @@ class SwitchTab(bpy.types.Operator): bl_description = "Switches to the last used tab" def execute(self, context): - aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)] + aprops = tool.Blender.get_area_properties(context) aprops.tab = aprops.alt_tab return {"FINISHED"} diff --git a/src/blenderbim/blenderbim/bim/ui.py b/src/blenderbim/blenderbim/bim/ui.py index 6cd253fbef..2825e20a49 100644 --- a/src/blenderbim/blenderbim/bim/ui.py +++ b/src/blenderbim/blenderbim/bim/ui.py @@ -278,7 +278,7 @@ class BIM_PT_root(Panel): bl_options = {"HIDE_HEADER"} def draw(self, context): - aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)] + aprops = tool.Blender.get_area_properties(context) row = self.layout.row(align=True) row.prop(aprops, "tab", text="") row.operator("bim.switch_tab", text="", icon="UV_SYNC_SELECT") @@ -292,8 +292,8 @@ class BIM_PT_project_info(Panel): @classmethod def poll(cls, context): - aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)] - return aprops.tab == "PROJECT" + aprops = tool.Blender.get_area_properties(context) + return aprops.tab == "PROJECT" or context.area.spaces.active.search_filter def draw(self, context): pass @@ -308,8 +308,8 @@ class BIM_PT_project_setup(Panel): @classmethod def poll(cls, context): - aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)] - return aprops.tab == "PROJECT" + aprops = tool.Blender.get_area_properties(context) + return aprops.tab == "PROJECT" or context.area.spaces.active.search_filter def draw(self, context): pass @@ -324,8 +324,8 @@ class BIM_PT_collaboration(Panel): @classmethod def poll(cls, context): - aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)] - return aprops.tab == "OTHER" + aprops = tool.Blender.get_area_properties(context) + return aprops.tab == "OTHER" or context.area.spaces.active.search_filter def draw(self, context): pass @@ -340,8 +340,8 @@ class BIM_PT_selection(Panel): @classmethod def poll(cls, context): - aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)] - return aprops.tab == "PROJECT" and tool.Ifc.get() + aprops = tool.Blender.get_area_properties(context) + return (aprops.tab == "PROJECT" or context.area.spaces.active.search_filter) and tool.Ifc.get() def draw(self, context): pass @@ -356,8 +356,8 @@ class BIM_PT_geometry(Panel): @classmethod def poll(cls, context): - aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)] - return aprops.tab == "PROJECT" and tool.Ifc.get() + aprops = tool.Blender.get_area_properties(context) + return (aprops.tab == "PROJECT" or context.area.spaces.active.search_filter) and tool.Ifc.get() def draw(self, context): pass @@ -372,8 +372,8 @@ class BIM_PT_4D5D(Panel): @classmethod def poll(cls, context): - aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)] - return aprops.tab == "SCHEDULING" and tool.Ifc.get() + aprops = tool.Blender.get_area_properties(context) + return (aprops.tab == "SCHEDULING" or context.area.spaces.active.search_filter) and tool.Ifc.get() def draw(self, context): pass @@ -388,8 +388,8 @@ class BIM_PT_structural(Panel): @classmethod def poll(cls, context): - aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)] - return aprops.tab == "STRUCTURE" and tool.Ifc.get() + aprops = tool.Blender.get_area_properties(context) + return (aprops.tab == "STRUCTURE" or context.area.spaces.active.search_filter) and tool.Ifc.get() def draw(self, context): pass @@ -404,8 +404,8 @@ class BIM_PT_services(Panel): @classmethod def poll(cls, context): - aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)] - return aprops.tab == "SERVICES" and tool.Ifc.get() + aprops = tool.Blender.get_area_properties(context) + return (aprops.tab == "SERVICES" or context.area.spaces.active.search_filter) and tool.Ifc.get() def draw(self, context): pass @@ -420,8 +420,8 @@ class BIM_PT_quality_control(Panel): @classmethod def poll(cls, context): - aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)] - return aprops.tab == "OTHER" + aprops = tool.Blender.get_area_properties(context) + return aprops.tab == "OTHER" or context.area.spaces.active.search_filter def draw(self, context): pass @@ -436,8 +436,8 @@ class BIM_PT_integrations(Panel): @classmethod def poll(cls, context): - aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)] - return aprops.tab == "OTHER" + aprops = tool.Blender.get_area_properties(context) + return aprops.tab == "OTHER" or context.area.spaces.active.search_filter def draw(self, context): pass diff --git a/src/blenderbim/blenderbim/tool/blender.py b/src/blenderbim/blenderbim/tool/blender.py index 4d9867aacc..453a97e9c2 100644 --- a/src/blenderbim/blenderbim/tool/blender.py +++ b/src/blenderbim/blenderbim/tool/blender.py @@ -151,6 +151,18 @@ class Blender: for attr in VIEWPORT_ATTRIBUTES: setattr(region_3d, attr, data[attr]) + @classmethod + def get_area_properties(cls, context): + areas = context.screen.areas[:] + current_area = context.area + # if user is using search from different properties tab (not SCENE) + # it will create new area that's not present in context.screen.areas + if current_area not in areas: + current_area = next(a for a in context.screen.areas if a.x == current_area.x and a.y == current_area.y) + area_i = areas.index(current_area) + + return context.screen.BIMAreaProperties[area_i] + @classmethod def get_shader_editor_context(cls): for screen in bpy.data.screens: