From b2a6e6a899544ed4759cb93ac7ca4f15f1e41836 Mon Sep 17 00:00:00 2001 From: pullusb Date: Wed, 23 Nov 2022 15:25:28 +0100 Subject: [PATCH] Set Brush operator 2.1.2 - added: `gp.brush_set` operator to manually assign a brush by name to a shortcut - preferably add shortcut to `Grease Pencil > Grease Pencil Stroke Paint Mode` --- CHANGELOG.md | 11 +++++++++++ OP_brushes.py | 21 +++++++++++++++++++++ __init__.py | 2 +- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bba1b8..87fda17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +2.1.2 + +- added: `gp.brush_set` operator to manually assign a brush by name to a shortcut + - preferably add shortcut to `Grease Pencil > Grease Pencil Stroke Paint Mode` + +2.1.1 + +- added: follow curve show offset property in UI +- added: follow curve show clickable warning if object has non-zero location to reset location +- changed: created follow curve use `fixed offset` + 2.1.1 - added: follow curve show offset property in UI diff --git a/OP_brushes.py b/OP_brushes.py index 82b2d3e..d8db3ae 100644 --- a/OP_brushes.py +++ b/OP_brushes.py @@ -48,6 +48,26 @@ class GPTB_OT_load_brushes(bpy.types.Operator, ImportHelper): return {"FINISHED"} +class GPTB_OT_brush_set(bpy.types.Operator): + bl_idname = "gp.brush_set" + bl_label = "Set Brush" + bl_description = "Set Gpencil brush" + bl_options = {"REGISTER", "UNDO"} + + brush_name : bpy.props.StringProperty(name='Brush', description='Name of the brush to use') + + @classmethod + def poll(cls, context): + return context.object and context.mode == 'PAINT_GPENCIL' + + def execute(self, context): + brush = bpy.data.brushes.get(self.brush_name) + if not brush: + self.report({'ERROR'}, f'Brush "{self.brush_name}" not found') + return {"CANCELLED"} + context.scene.tool_settings.gpencil_paint.brush = brush + return {"FINISHED"} + ### -- MENU ENTRY -- def load_brush_ui(self, context): @@ -62,6 +82,7 @@ def load_brush_top_bar_ui(self, context): classes = ( GPTB_OT_load_brushes, +GPTB_OT_brush_set, ) def register(): diff --git a/__init__.py b/__init__.py index 7766ed3..02f5f09 100755 --- a/__init__.py +++ b/__init__.py @@ -4,7 +4,7 @@ bl_info = { "name": "GP toolbox", "description": "Tool set for Grease Pencil in animation production", "author": "Samuel Bernou, Christophe Seux", -"version": (2, 1, 1), +"version": (2, 1, 2), "blender": (3, 0, 0), "location": "Sidebar (N menu) > Gpencil > Toolbox / Gpencil properties", "warning": "",