From eae69b6f7596b68f3293939fce0da057a4cf1b9a Mon Sep 17 00:00:00 2001 From: pullusb Date: Mon, 11 Nov 2024 15:47:33 +0100 Subject: [PATCH] update to gpv3 context modes --- OP_brushes.py | 6 +++--- OP_eraser_brush.py | 6 +++--- OP_file_checker.py | 2 +- OP_flat_reproject.py | 4 ++-- OP_follow_curve.py | 2 +- OP_layer_manager.py | 2 +- OP_layer_picker.py | 2 +- OP_material_picker.py | 4 ++-- OP_realign.py | 6 +++--- TOOL_eraser_brush.py | 2 +- UI_tools.py | 4 ++-- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/OP_brushes.py b/OP_brushes.py index f24dcd5..b4f4741 100644 --- a/OP_brushes.py +++ b/OP_brushes.py @@ -58,7 +58,7 @@ class GPTB_OT_brush_set(bpy.types.Operator): @classmethod def poll(cls, context): - return context.object and context.mode == 'PAINT_GPENCIL' + return context.object and context.mode == 'PAINT_GREASE_PENCIL' def execute(self, context): brush = bpy.data.brushes.get(self.brush_name) @@ -72,12 +72,12 @@ class GPTB_OT_brush_set(bpy.types.Operator): def load_brush_ui(self, context): prefs = get_addon_prefs() - if context.mode == 'PAINT_GPENCIL': + if context.mode == 'PAINT_GREASE_PENCIL': self.layout.operator('gp.load_brushes', icon='KEYTYPE_JITTER_VEC').filepath = prefs.brush_path def load_brush_top_bar_ui(self, context): prefs = get_addon_prefs() - if context.mode == 'PAINT_GPENCIL': + if context.mode == 'PAINT_GREASE_PENCIL': self.layout.operator('gp.load_brushes').filepath = prefs.brush_path classes = ( diff --git a/OP_eraser_brush.py b/OP_eraser_brush.py index b826d9c..9b42631 100644 --- a/OP_eraser_brush.py +++ b/OP_eraser_brush.py @@ -259,7 +259,7 @@ class GPTB_OT_eraser(Operator): #bpy.data.materials.remove(self.hld_mat) - bpy.ops.object.mode_set(mode='EDIT_GPENCIL') + bpy.ops.object.mode_set(mode='EDIT') context.scene.tool_settings.gpencil_selectmode_edit = 'POINT' #context.scene.tool_settings.gpencil_selectmode_edit = 'POINT' @@ -358,9 +358,9 @@ class GPTB_OT_eraser(Operator): #bpy.ops.object.mode_set(mode='OBJECT') context.scene.tool_settings.gpencil_selectmode_edit = self.gpencil_selectmode_edit - bpy.ops.object.mode_set(mode='PAINT_GPENCIL') + bpy.ops.object.mode_set(mode='PAINT_GREASE_PENCIL') #selected_strokes = [s for s in self.gp_frame.strokes if s.select] - #bpy.ops.object.mode_set(mode='PAINT_GPENCIL') + #bpy.ops.object.mode_set(mode='PAINT_GREASE_PENCIL') def modal(self, context, event): self.mouse = Vector((event.mouse_region_x, event.mouse_region_y)) diff --git a/OP_file_checker.py b/OP_file_checker.py index 4253f7a..a26fc4a 100755 --- a/OP_file_checker.py +++ b/OP_file_checker.py @@ -120,7 +120,7 @@ class GPTB_OT_file_checker(bpy.types.Operator): setattr(area.spaces[0], 'show_locked_time', True) ## set cursor type - if context.mode in ("EDIT_GPENCIL", "SCULPT_GPENCIL"): + if context.mode in ("EDIT_GREASE_PENCIL", "SCULPT_GREASE_PENCIL"): tool = fix.select_active_tool if tool != 'none': if bpy.context.workspace.tools.from_space_view3d_mode(bpy.context.mode, create=False).idname != tool: diff --git a/OP_flat_reproject.py b/OP_flat_reproject.py index b7d4ef3..8a20112 100644 --- a/OP_flat_reproject.py +++ b/OP_flat_reproject.py @@ -132,12 +132,12 @@ class GPTB_OT_batch_flat_reproject(bpy.types.Operator): ### -- MENU ENTRY -- def flat_reproject_clean_menu(self, context): - if context.mode == 'EDIT_GPENCIL': + if context.mode == 'EDIT_GREASE_PENCIL': self.layout.operator_context = 'INVOKE_REGION_WIN' # needed for popup (also works with 'INVOKE_DEFAULT') self.layout.operator('gp.batch_flat_reproject', icon='KEYTYPE_JITTER_VEC') def flat_reproject_context_menu(self, context): - if context.mode == 'EDIT_GPENCIL' and context.scene.tool_settings.gpencil_selectmode_edit == 'STROKE': + if context.mode == 'EDIT_GREASE_PENCIL' and context.scene.tool_settings.gpencil_selectmode_edit == 'STROKE': self.layout.operator_context = 'INVOKE_REGION_WIN' # needed for popup self.layout.operator('gp.batch_flat_reproject', icon='KEYTYPE_JITTER_VEC') diff --git a/OP_follow_curve.py b/OP_follow_curve.py index 9c1e573..5a1b285 100644 --- a/OP_follow_curve.py +++ b/OP_follow_curve.py @@ -136,7 +136,7 @@ class GPTB_OT_go_to_object(bpy.types.Operator): self.report({'INFO'}, f'Back to pose mode, {obj.name}') elif obj.type == 'GREASEPENCIL': - bpy.ops.object.mode_set(mode='PAINT_GPENCIL', toggle=False) + bpy.ops.object.mode_set(mode='PAINT_GREASE_PENCIL', toggle=False) else: self.report({'INFO'}, f'Back to object mode, {obj.name}') diff --git a/OP_layer_manager.py b/OP_layer_manager.py index 73fd7e2..2170629 100644 --- a/OP_layer_manager.py +++ b/OP_layer_manager.py @@ -557,7 +557,7 @@ def layer_name_builder_ui(self, context): return layout = self.layout - # {'EDIT_GPENCIL', 'PAINT_GPENCIL','SCULPT_GPENCIL','WEIGHT_GPENCIL', 'VERTEX_GPENCIL'} + # {'EDIT_GREASE_PENCIL', 'PAINT_GREASE_PENCIL','SCULPT_GREASE_PENCIL','WEIGHT_GREASE_PENCIL', 'VERTEX_GPENCIL'} # layout.separator() col = layout.column() diff --git a/OP_layer_picker.py b/OP_layer_picker.py index 675506b..5134fdc 100644 --- a/OP_layer_picker.py +++ b/OP_layer_picker.py @@ -14,7 +14,7 @@ class GP_OT_pick_closest_layer(Operator): @classmethod def poll(cls, context): - return context.object and context.object.type == 'GREASEPENCIL' and context.mode == 'PAINT_GPENCIL' + return context.object and context.object.type == 'GREASEPENCIL' and context.mode == 'PAINT_GREASE_PENCIL' stroke_filter : bpy.props.EnumProperty(name='Target', default='STROKE', diff --git a/OP_material_picker.py b/OP_material_picker.py index e7d9ea5..cf6eea8 100644 --- a/OP_material_picker.py +++ b/OP_material_picker.py @@ -33,7 +33,7 @@ class GP_OT_pick_closest_material(Operator): @classmethod def poll(cls, context): - return context.object and context.object.type == 'GREASEPENCIL' and context.mode == 'PAINT_GPENCIL' + return context.object and context.object.type == 'GREASEPENCIL' and context.mode == 'PAINT_GREASE_PENCIL' fill_only : bpy.props.BoolProperty(default=False, options={'SKIP_SAVE'}) @@ -159,7 +159,7 @@ class GP_OT_pick_closest_material(Operator): @classmethod def poll(cls, context): - return context.object and context.object.type == 'GREASEPENCIL' and context.mode == 'PAINT_GPENCIL' + return context.object and context.object.type == 'GREASEPENCIL' and context.mode == 'PAINT_GREASE_PENCIL' # fill_only : bpy.props.BoolProperty(default=False, options={'SKIP_SAVE'}) stroke_filter : bpy.props.EnumProperty(default='FILL', diff --git a/OP_realign.py b/OP_realign.py index 9f74ebf..ac6c802 100644 --- a/OP_realign.py +++ b/OP_realign.py @@ -25,7 +25,7 @@ if all_strokes: l.hide = False l.lock = False l.lock_frame = False -bpy.ops.object.mode_set(mode='EDIT_GPENCIL') +bpy.ops.object.mode_set(mode='EDIT') for fnum in frame_list: @@ -432,12 +432,12 @@ class GPTB_OT_batch_reproject_all_frames(bpy.types.Operator): ### -- MENU ENTRY -- def reproject_clean_menu(self, context): - if context.mode == 'EDIT_GPENCIL': + if context.mode == 'EDIT_GREASE_PENCIL': self.layout.operator_context = 'INVOKE_REGION_WIN' # needed for popup (also works with 'INVOKE_DEFAULT') self.layout.operator('gp.batch_reproject_all_frames', icon='KEYTYPE_JITTER_VEC') def reproject_context_menu(self, context): - if context.mode == 'EDIT_GPENCIL' and context.scene.tool_settings.gpencil_selectmode_edit == 'STROKE': + if context.mode == 'EDIT_GREASE_PENCIL' and context.scene.tool_settings.gpencil_selectmode_edit == 'STROKE': self.layout.operator_context = 'INVOKE_REGION_WIN' # needed for popup self.layout.operator('gp.batch_reproject_all_frames', icon='KEYTYPE_JITTER_VEC') diff --git a/TOOL_eraser_brush.py b/TOOL_eraser_brush.py index bc3376d..75945df 100644 --- a/TOOL_eraser_brush.py +++ b/TOOL_eraser_brush.py @@ -7,7 +7,7 @@ from .utils import get_addon_prefs class GPTB_WT_eraser(WorkSpaceTool): bl_space_type = 'VIEW_3D' - bl_context_mode = 'PAINT_GPENCIL' + bl_context_mode = 'PAINT_GREASE_PENCIL' # The prefix of the idname should be your add-on name. bl_idname = "gp.eraser_tool" diff --git a/UI_tools.py b/UI_tools.py index 400cbc0..02859f8 100644 --- a/UI_tools.py +++ b/UI_tools.py @@ -425,7 +425,7 @@ def palette_manager_menu(self, context): """Palette menu to append in existing menu""" # GPENCIL_MT_material_context_menu layout = self.layout - # {'EDIT_GPENCIL', 'PAINT_GPENCIL','SCULPT_GPENCIL','WEIGHT_GPENCIL', 'VERTEX_GPENCIL'} + # {'EDIT_GREASE_PENCIL', 'PAINT_GREASE_PENCIL','SCULPT_GREASE_PENCIL','WEIGHT_GREASE_PENCIL', 'VERTEX_GPENCIL'} layout.separator() prefs = get_addon_prefs() @@ -658,7 +658,7 @@ class GPTB_PT_tools_grease_pencil_interpolate(Panel): # settings = context.tool_settings.gpencil_interpolate # old 2.92 global settings ## access active tool settings # settings = context.workspace.tools[0].operator_properties('gpencil.interpolate') - settings = context.workspace.tools.from_space_view3d_mode('PAINT_GPENCIL').operator_properties('gpencil.interpolate') + settings = context.workspace.tools.from_space_view3d_mode('PAINT_GREASE_PENCIL').operator_properties('gpencil.interpolate') ## custom curve access (still in gp interpolate tools) interpolate_settings = context.tool_settings.gpencil_interpolate