Brushstroke Tools: Initial Version #328

Merged
Simon Thommes merged 229 commits from SimonThommes/blender-studio-tools:brushstroke_tools-initial-version into main 2024-11-06 15:03:47 +01:00
2 changed files with 32 additions and 0 deletions
Showing only changes of commit 10762817d6 - Show all commits

View File

@ -247,6 +247,36 @@ class BSBST_OT_delete_brushstrokes(bpy.types.Operator):
settings.edit_toggle = edit_toggle settings.edit_toggle = edit_toggle
return {'FINISHED'} return {'FINISHED'}
class BSBST_OT_select_surface(bpy.types.Operator):
"""
Select the surface object for the active context brushstrokes.
"""
bl_idname = "brushstroke_tools.select_surface"
bl_label = "Select Surface"
bl_description = "Select the surface object for the active context brushstrokes"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
settings = context.scene.BSBST_settings
return bool(settings.context_brushstrokes)
def execute(self, context):
bs_ob = utils.get_active_context_brushstrokes_object(context)
if not bs_ob:
return {"CANCELLED"}
surface_object = getattr(bs_ob, '["BSBST_surface_object"]', None)
if not surface_object:
return {"CANCELLED"}
bpy.context.view_layer.objects.active = surface_object
bpy.ops.object.mode_set(mode='OBJECT')
for ob in bpy.data.objects:
ob.select_set(False)
surface_object.select_set(True)
return {"FINISHED"}
class BSBST_OT_init_preset(bpy.types.Operator): class BSBST_OT_init_preset(bpy.types.Operator):
""" """
@ -535,6 +565,7 @@ classes = [
BSBST_OT_new_brushstrokes, BSBST_OT_new_brushstrokes,
BSBST_OT_edit_brushstrokes, BSBST_OT_edit_brushstrokes,
BSBST_OT_delete_brushstrokes, BSBST_OT_delete_brushstrokes,
BSBST_OT_select_surface,
BSBST_OT_init_preset, BSBST_OT_init_preset,
BSBST_OT_make_preset, BSBST_OT_make_preset,
BSBST_OT_preset_add_mod, BSBST_OT_preset_add_mod,

View File

@ -225,6 +225,7 @@ class BSBST_PT_brushstroke_tools_panel(bpy.types.Panel):
if not is_preset and len(settings.context_brushstrokes)>0: if not is_preset and len(settings.context_brushstrokes)>0:
row = style_panel.row() row = style_panel.row()
row_edit = row.row(align=True) row_edit = row.row(align=True)
row_edit.operator('brushstroke_tools.select_surface', icon='OUTLINER_OB_SURFACE', text='')
row_edit.operator('brushstroke_tools.edit_brushstrokes', icon='GREASEPENCIL') row_edit.operator('brushstroke_tools.edit_brushstrokes', icon='GREASEPENCIL')
row_edit.prop(settings, 'edit_toggle', icon='RESTRICT_SELECT_OFF' if settings.edit_toggle else 'RESTRICT_SELECT_ON', icon_only=True) row_edit.prop(settings, 'edit_toggle', icon='RESTRICT_SELECT_OFF' if settings.edit_toggle else 'RESTRICT_SELECT_ON', icon_only=True)
row.operator('brushstroke_tools.delete_brushstrokes', text='', icon='TRASH') row.operator('brushstroke_tools.delete_brushstrokes', text='', icon='TRASH')