From ad01945561282b14d3205c071e8910a03d6599ed Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Mon, 15 Apr 2024 00:01:42 +1000 Subject: [PATCH] Fix #4549. Drawing decorators are now refreshed like the rest of the UI after operations. --- src/blenderbim/blenderbim/bim/handler.py | 2 ++ src/blenderbim/blenderbim/bim/module/drawing/__init__.py | 4 ++-- src/blenderbim/blenderbim/bim/module/drawing/handler.py | 2 +- src/blenderbim/blenderbim/bim/module/drawing/prop.py | 7 +++---- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/handler.py b/src/blenderbim/blenderbim/bim/handler.py index 4e9228186a..28306671de 100644 --- a/src/blenderbim/blenderbim/bim/handler.py +++ b/src/blenderbim/blenderbim/bim/handler.py @@ -192,6 +192,8 @@ def refresh_ui_data(): if isinstance(tool.Ifc.get(), ifcopenshell.sqlite): tool.Ifc.get().clear_cache() + bpy.context.scene.DocProperties.should_draw_decorations = bpy.context.scene.DocProperties.should_draw_decorations + @persistent def loadIfcStore(scene): diff --git a/src/blenderbim/blenderbim/bim/module/drawing/__init__.py b/src/blenderbim/blenderbim/bim/module/drawing/__init__.py index 643955fee5..18227bed86 100644 --- a/src/blenderbim/blenderbim/bim/module/drawing/__init__.py +++ b/src/blenderbim/blenderbim/bim/module/drawing/__init__.py @@ -127,7 +127,7 @@ def register(): bpy.types.Object.BIMAssignedProductProperties = bpy.props.PointerProperty(type=prop.BIMAssignedProductProperties) bpy.types.Object.BIMTextProperties = bpy.props.PointerProperty(type=prop.BIMTextProperties) bpy.types.TextCurve.BIMTextProperties = bpy.props.PointerProperty(type=prop.BIMTextProperties) - bpy.app.handlers.load_post.append(handler.toggleDecorationsOnLoad) + bpy.app.handlers.load_post.append(handler.load_post) bpy.app.handlers.depsgraph_update_pre.append(handler.depsgraph_update_pre_handler) bpy.types.VIEW3D_MT_image_add.append(ui.add_object_button) @@ -141,6 +141,6 @@ def unregister(): del bpy.types.Object.BIMAssignedProductProperties del bpy.types.Object.BIMTextProperties del bpy.types.TextCurve.BIMTextProperties - bpy.app.handlers.load_post.remove(handler.toggleDecorationsOnLoad) + bpy.app.handlers.load_post.remove(handler.load_post) bpy.app.handlers.depsgraph_update_pre.remove(handler.depsgraph_update_pre_handler) bpy.types.VIEW3D_MT_image_add.remove(ui.add_object_button) diff --git a/src/blenderbim/blenderbim/bim/module/drawing/handler.py b/src/blenderbim/blenderbim/bim/module/drawing/handler.py index d553fcb113..9e45415d8f 100644 --- a/src/blenderbim/blenderbim/bim/module/drawing/handler.py +++ b/src/blenderbim/blenderbim/bim/module/drawing/handler.py @@ -23,7 +23,7 @@ from bpy.app.handlers import persistent @persistent -def toggleDecorationsOnLoad(*args): +def load_post(*args): if bpy.context.scene.DocProperties.should_draw_decorations: decoration.DecorationsHandler.install(bpy.context) else: diff --git a/src/blenderbim/blenderbim/bim/module/drawing/prop.py b/src/blenderbim/blenderbim/bim/module/drawing/prop.py index 3cdafc8144..eedfefaee8 100644 --- a/src/blenderbim/blenderbim/bim/module/drawing/prop.py +++ b/src/blenderbim/blenderbim/bim/module/drawing/prop.py @@ -231,9 +231,8 @@ def update_titleblocks(self, context): SheetsData.data["titleblocks"] = SheetsData.titleblocks() -def toggleDecorations(self, context): - toggle = self.should_draw_decorations - if toggle: +def update_should_draw_decorations(self, context): + if self.should_draw_decorations: # TODO: design a proper text variable templating renderer collection = context.scene.camera.BIMObjectProperties.collection for obj in collection.objects: @@ -345,7 +344,7 @@ class DocProperties(PropertyGroup): active_sheet_index: IntProperty(name="Active Sheet Index") ifc_files: CollectionProperty(name="IFCs", type=StrProperty) drawing_styles: CollectionProperty(name="Drawing Styles", type=DrawingStyle) - should_draw_decorations: BoolProperty(name="Should Draw Decorations", update=toggleDecorations) + should_draw_decorations: BoolProperty(name="Should Draw Decorations", update=update_should_draw_decorations) sheets_dir: StringProperty(default=os.path.join("sheets") + os.path.sep, name="Default Sheets Directory") layouts_dir: StringProperty(default=os.path.join("layouts") + os.path.sep, name="Default Layouts Directory") titleblocks_dir: StringProperty(