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 48 additions and 4 deletions
Showing only changes of commit 5885226c48 - Show all commits

View File

@ -190,7 +190,7 @@ class BSBST_OT_edit_brushstrokes(bpy.types.Operator):
Enter the editing context for the active context brushstrokes.
"""
bl_idname = "brushstroke_tools.edit_brushstrokes"
bl_label = "Edit Active Brushstrokes"
bl_label = "Edit Brushstrokes"
bl_description = " Enter the editing context for the active context brushstrokes"
bl_options = {"REGISTER", "UNDO"}
@ -202,6 +202,47 @@ class BSBST_OT_edit_brushstrokes(bpy.types.Operator):
def execute(self, context):
return utils.edit_active_brushstrokes(context)
class BSBST_OT_delete_brushstrokes(bpy.types.Operator):
"""
Delete the active context brushstrokes
"""
bl_idname = "brushstroke_tools.delete_brushstrokes"
bl_label = "Delete Brushstrokes"
bl_description = " Delete 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):
settings = context.scene.BSBST_settings
edit_toggle = settings.edit_toggle
settings.edit_toggle = False
active_bs = settings.context_brushstrokes[settings.active_context_brushstrokes_index]
bs_ob = bpy.data.objects.get(active_bs.name)
if not bs_ob:
return {"CANCELLED"}
flow_object = utils.get_flow_object(bs_ob)
bpy.ops.object.mode_set(mode='OBJECT')
bpy.data.objects.remove(bs_ob)
settings.active_context_brushstrokes_index = max(0, settings.active_context_brushstrokes_index-1)
if not flow_object:
return {"FINISHED"}
# delete controller objects
if flow_object.users <= 1:
bpy.data.objects.remove(flow_object)
settings.edit_toggle = edit_toggle
return {'FINISHED'}
class BSBST_OT_init_preset(bpy.types.Operator):
"""
Initialize the preset to define a modifier stack applied to new brushstrokess.
@ -447,6 +488,7 @@ class BSBST_OT_preset_toggle_attribute(bpy.types.Operator):
classes = [
BSBST_OT_new_brushstrokes,
BSBST_OT_edit_brushstrokes,
BSBST_OT_delete_brushstrokes,
BSBST_OT_init_preset,
BSBST_OT_make_preset,
BSBST_OT_preset_add_mod,

View File

@ -223,11 +223,13 @@ class BSBST_PT_brushstroke_tools_panel(bpy.types.Panel):
style_panel.label(text='No Brushstroke Context Found', icon='ERROR')
return
if not is_preset and len(settings.context_brushstrokes)>0:
row = style_panel.row()
row_edit = row.row(align=True)
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.operator('brushstroke_tools.delete_brushstrokes', text='', icon='TRASH')
style_panel.template_list("BSBST_UL_brushstroke_objects", "", settings, "context_brushstrokes",
settings, "active_context_brushstrokes_index", rows=1, maxrows=5, sort_lock=True)
row = style_panel.row(align=True)
row.operator('brushstroke_tools.edit_brushstrokes', icon='GREASEPENCIL')
row.prop(settings, 'edit_toggle', icon='RESTRICT_SELECT_OFF' if settings.edit_toggle else 'RESTRICT_SELECT_ON', icon_only=True)
style_panel.prop(settings, 'preset_material', icon='MATERIAL')
if not settings.preset_object and is_preset:
style_panel.operator("brushstroke_tools.init_preset", icon='MODIFIER')