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