From d032f75e61188df523ab46035def87de488e64f4 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Tue, 19 Nov 2024 15:06:44 +0500 Subject: [PATCH] Fix error updating decorations removing active drawing should_draw_decorations is updated as part of regular refresh_ui_data. 'removed_drawings' line was a dead code Traceback (most recent call last): File \bonsai\bim\module\drawing\prop.py", line 252, in update_should_draw_decorations collection = context.scene.camera.BIMObjectProperties.collection ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'BIMObjectProperties' File \bonsai\bim\module\drawing\prop.py", line 249, in update_should_draw_decorations --- src/bonsai/bonsai/bim/module/drawing/operator.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/drawing/operator.py b/src/bonsai/bonsai/bim/module/drawing/operator.py index bf05fc4119..88a1bdd94c 100644 --- a/src/bonsai/bonsai/bim/module/drawing/operator.py +++ b/src/bonsai/bonsai/bim/module/drawing/operator.py @@ -2128,6 +2128,7 @@ class RemoveDrawing(bpy.types.Operator, tool.Ifc.Operator): return self.execute(context) def _execute(self, context): + props = context.scene.DocProperties if self.remove_all: drawings = [ tool.Ifc.get().by_id(d.ifc_definition_id) @@ -2140,14 +2141,16 @@ class RemoveDrawing(bpy.types.Operator, tool.Ifc.Operator): return {"CANCELLED"} drawings = [tool.Ifc.get().by_id(self.drawing)] - removed_drawings = [drawing.id() for drawing in drawings] - for drawing in drawings: sheet_references = tool.Drawing.get_sheet_references(drawing) for reference in sheet_references: bpy.ops.bim.remove_drawing_from_sheet(reference=reference.id()) core.remove_drawing(tool.Ifc, tool.Drawing, drawing=drawing) + # In case we removed the active drawing. + if not context.scene.camera and props.should_draw_decorations: + props.should_draw_decorations = False + class ReloadDrawingStyles(bpy.types.Operator): bl_idname = "bim.reload_drawing_styles"