diff --git a/src/bonsai/bonsai/bim/module/drawing/operator.py b/src/bonsai/bonsai/bim/module/drawing/operator.py index 72014d838c..e606b1e1cb 100644 --- a/src/bonsai/bonsai/bim/module/drawing/operator.py +++ b/src/bonsai/bonsai/bim/module/drawing/operator.py @@ -1779,7 +1779,7 @@ class SaveDrawingStyle(bpy.types.Operator, tool.Ifc.Operator): if self.index: index = int(self.index) else: - index = context.active_object.data.BIMCameraProperties.active_drawing_style_index + index = context.scene.camera.data.BIMCameraProperties.active_drawing_style_index scene.DocProperties.drawing_styles[index].raster_style = json.dumps(style) bpy.ops.bim.save_drawing_styles_data() @@ -2678,8 +2678,9 @@ class EditElementFilter(bpy.types.Operator, tool.Ifc.Operator): filter_mode: bpy.props.StringProperty() def _execute(self, context): - props = context.active_object.data.BIMCameraProperties obj = bpy.context.scene.camera + assert obj + props = obj.data.BIMCameraProperties element = tool.Ifc.get_entity(obj) pset = tool.Pset.get_element_pset(element, "EPset_Drawing") if self.filter_mode == "INCLUDE": diff --git a/src/bonsai/bonsai/bim/module/drawing/ui.py b/src/bonsai/bonsai/bim/module/drawing/ui.py index 47a6f67b70..0313286f20 100644 --- a/src/bonsai/bonsai/bim/module/drawing/ui.py +++ b/src/bonsai/bonsai/bim/module/drawing/ui.py @@ -106,11 +106,7 @@ class BIM_PT_element_filters(Panel): @classmethod def poll(cls, context): - return ( - context.scene.camera - and context.active_object - and hasattr(context.active_object.data, "BIMCameraProperties") - ) + return bool((camera := context.scene.camera) and tool.Ifc.get_entity(camera)) def draw(self, context): if not ElementFiltersData.is_loaded: @@ -160,17 +156,15 @@ class BIM_PT_drawing_underlay(Panel): @classmethod def poll(cls, context): - return ( - context.scene.camera - and context.active_object - and hasattr(context.active_object.data, "BIMCameraProperties") - ) + return bool((camera := context.scene.camera) and tool.Ifc.get_entity(camera)) def draw(self, context): layout = self.layout layout.use_property_split = True + camera = context.scene.camera + assert camera dprops = context.scene.DocProperties - props = context.active_object.data.BIMCameraProperties + props = camera.data.BIMCameraProperties drawing_index_is_valid = props.active_drawing_style_index < len(dprops.drawing_styles) if not DrawingsData.is_loaded: