From 11b62a0fdc3f566a139f5bff3448ddcca62e13dc Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 29 Jul 2024 16:42:40 +0500 Subject: [PATCH] fix console errors adding new style and changing it's color 1) As adding new styles means it's not assigned anywhere, there is no need to keep graph up to date. 2) Removed Ifc Operator super class from couple operators that do not write ifc data 3) Moved common code to tool.Style --- .../blenderbim/bim/module/style/operator.py | 20 +++++++++---------- src/blenderbim/blenderbim/tool/style.py | 12 +++++++++++ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/style/operator.py b/src/blenderbim/blenderbim/bim/module/style/operator.py index e94e925404..da5079aae6 100644 --- a/src/blenderbim/blenderbim/bim/module/style/operator.py +++ b/src/blenderbim/blenderbim/bim/module/style/operator.py @@ -535,22 +535,22 @@ class RemoveTextureMap(bpy.types.Operator): return {"FINISHED"} -class EnableAddingPresentationStyle(bpy.types.Operator, tool.Ifc.Operator): +class EnableAddingPresentationStyle(bpy.types.Operator): bl_idname = "bim.enable_adding_presentation_style" bl_label = "Enable Add Presentation Style" bl_options = {"REGISTER", "UNDO"} @classmethod def poll(cls, context): - style_type = bpy.context.scene.BIMStylesProperties.style_type + style_type = tool.Style.get_active_style_type() if style_type != "IfcSurfaceStyle": cls.poll_message_set(f"Adding {style_type} is not currently supported.") return False return True - def _execute(self, context): - props = bpy.context.scene.BIMStylesProperties - props.is_adding = True + def execute(self, context): + tool.Style.enable_adding_presentation_style() + return {"FINISHED"} class DuplicateStyle(bpy.types.Operator, tool.Ifc.Operator): @@ -569,14 +569,14 @@ class DuplicateStyle(bpy.types.Operator, tool.Ifc.Operator): bpy.ops.bim.load_styles(style_type=style_type) -class DisableAddingPresentationStyle(bpy.types.Operator, tool.Ifc.Operator): +class DisableAddingPresentationStyle(bpy.types.Operator): bl_idname = "bim.disable_adding_presentation_style" bl_label = "Disable Add Presentation Style" bl_options = {"REGISTER", "UNDO"} - def _execute(self, context): - props = bpy.context.scene.BIMStylesProperties - props.is_adding = False + def execute(self, context): + tool.Style.disable_adding_presentation_style() + return {"FINISHED"} class AddPresentationStyle(bpy.types.Operator, tool.Ifc.Operator): @@ -629,7 +629,7 @@ class AddPresentationStyle(bpy.types.Operator, tool.Ifc.Operator): else: self.report({"INFO"}, f"Adding style of type {props.style_type} is not yet supported.") - props.is_adding = False + tool.Style.disable_adding_presentation_style() core.load_styles(tool.Style, style_type=props.style_type) diff --git a/src/blenderbim/blenderbim/tool/style.py b/src/blenderbim/blenderbim/tool/style.py index fc0de8849f..9ce8056b39 100644 --- a/src/blenderbim/blenderbim/tool/style.py +++ b/src/blenderbim/blenderbim/tool/style.py @@ -55,6 +55,18 @@ class Style(blenderbim.core.tool.Style): def delete_object(cls, obj: bpy.types.Material) -> None: tool.Blender.remove_data_block(obj) + @classmethod + def enable_adding_presentation_style(cls) -> None: + props = bpy.context.scene.BIMStylesProperties + props.is_adding = True + props.update_graph = False + + @classmethod + def disable_adding_presentation_style(cls) -> None: + props = bpy.context.scene.BIMStylesProperties + props.is_adding = False + props.update_graph = True + @classmethod def disable_editing(cls) -> None: bpy.context.scene.BIMStylesProperties.is_editing_style = 0