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 24 additions and 7 deletions
Showing only changes of commit 59f766923b - Show all commits

View File

@ -85,10 +85,8 @@ class BSBST_OT_new_brushstrokes(bpy.types.Operator):
utils.set_deformable(flow_object, settings.deforming_surface) utils.set_deformable(flow_object, settings.deforming_surface)
return flow_object return flow_object
def execute(self, context): def main(self, context):
settings = context.scene.BSBST_settings settings = context.scene.BSBST_settings
edit_toggle = settings.edit_toggle
utils.ensure_resources() utils.ensure_resources()
if not context.mode == 'OBJECT': if not context.mode == 'OBJECT':
@ -236,6 +234,14 @@ class BSBST_OT_new_brushstrokes(bpy.types.Operator):
utils.edit_active_brushstrokes(context) utils.edit_active_brushstrokes(context)
return {"FINISHED"} return {"FINISHED"}
def execute(self, context):
settings = context.scene.BSBST_settings
settings.silent_switch = True
state = self.main(context)
settings.silent_switch = False
return state
class BSBST_OT_edit_brushstrokes(bpy.types.Operator): class BSBST_OT_edit_brushstrokes(bpy.types.Operator):
""" """
Enter the editing context for the active context brushstrokes. Enter the editing context for the active context brushstrokes.
@ -251,7 +257,12 @@ class BSBST_OT_edit_brushstrokes(bpy.types.Operator):
return bool(settings.context_brushstrokes) return bool(settings.context_brushstrokes)
def execute(self, context): def execute(self, context):
return utils.edit_active_brushstrokes(context) settings = context.scene.BSBST_settings
settings.silent_switch = True
state = utils.edit_active_brushstrokes(context)
settings.silent_switch = False
return state
class BSBST_OT_delete_brushstrokes(bpy.types.Operator): class BSBST_OT_delete_brushstrokes(bpy.types.Operator):
""" """

View File

@ -39,6 +39,12 @@ def find_context_brushstrokes(dummy):
for el in range(len(settings.context_brushstrokes)): for el in range(len(settings.context_brushstrokes)):
settings.context_brushstrokes.remove(0) settings.context_brushstrokes.remove(0)
context_object = context.object context_object = context.object
if not is_brushstrokes_object(context_object):
bs_ob = is_flow_object(context_object)
if bs_ob:
context_object = bs_ob
else:
bs_ob = context_object
surf_ob = get_surface_object(context_object) surf_ob = get_surface_object(context_object)
if surf_ob: if surf_ob:
context_object = surf_ob context_object = surf_ob
@ -62,9 +68,9 @@ def find_context_brushstrokes(dummy):
if not settings.context_brushstrokes: if not settings.context_brushstrokes:
settings.edit_toggle = edit_toggle settings.edit_toggle = edit_toggle
return return
if context.object: if bs_ob:
for i, bs in enumerate(settings.context_brushstrokes): for i, bs in enumerate(settings.context_brushstrokes):
if bs.name == context.object.name: if bs.name == bs_ob.name:
settings.silent_switch = True settings.silent_switch = True
settings.active_context_brushstrokes_index = i settings.active_context_brushstrokes_index = i
settings.silent_switch = False settings.silent_switch = False
@ -429,7 +435,7 @@ def is_flow_object(object):
if 'BSBST_flow_object' not in ob.keys(): if 'BSBST_flow_object' not in ob.keys():
continue continue
if ob['BSBST_flow_object'] == object: if ob['BSBST_flow_object'] == object:
return True return ob
return False return False
def get_deformable(object): def get_deformable(object):