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 7 additions and 0 deletions
Showing only changes of commit 2fe146d897 - Show all commits

View File

@ -225,6 +225,7 @@ class BSBST_OT_delete_brushstrokes(bpy.types.Operator):
active_bs = settings.context_brushstrokes[settings.active_context_brushstrokes_index] active_bs = settings.context_brushstrokes[settings.active_context_brushstrokes_index]
bs_ob = bpy.data.objects.get(active_bs.name) bs_ob = bpy.data.objects.get(active_bs.name)
if not bs_ob: if not bs_ob:
settings.edit_toggle = edit_toggle
return {"CANCELLED"} return {"CANCELLED"}
flow_object = utils.get_flow_object(bs_ob) flow_object = utils.get_flow_object(bs_ob)
@ -234,6 +235,7 @@ class BSBST_OT_delete_brushstrokes(bpy.types.Operator):
settings.active_context_brushstrokes_index = max(0, settings.active_context_brushstrokes_index-1) settings.active_context_brushstrokes_index = max(0, settings.active_context_brushstrokes_index-1)
if not flow_object: if not flow_object:
settings.edit_toggle = edit_toggle
return {"FINISHED"} return {"FINISHED"}
# delete controller objects # delete controller objects

View File

@ -6,6 +6,9 @@ from bpy.app.handlers import persistent
def find_context_brushstrokes(dummy): def find_context_brushstrokes(dummy):
context = bpy.context context = bpy.context
settings = context.scene.BSBST_settings settings = context.scene.BSBST_settings
edit_toggle = settings.edit_toggle
settings.edit_toggle = False
len_prev = len(settings.context_brushstrokes) len_prev = len(settings.context_brushstrokes)
name_prev = settings.context_brushstrokes[settings.active_context_brushstrokes_index].name if len_prev else '' name_prev = settings.context_brushstrokes[settings.active_context_brushstrokes_index].name if len_prev else ''
idx = settings.active_context_brushstrokes_index idx = settings.active_context_brushstrokes_index
@ -34,6 +37,7 @@ def find_context_brushstrokes(dummy):
if name_prev == ob.name: if name_prev == ob.name:
idx = len(settings.context_brushstrokes)-1 idx = len(settings.context_brushstrokes)-1
SimonThommes marked this conversation as resolved Outdated

Generally, the code would be easier to read if line lengths were more limited. E.g. for Blender we have a 120 line length limit. That also makes it easier to have two files open next to each other. Such limits can be enforced automatically with auto-formatters like autopep8 (what we currently use in Blender) or e.g. black.

Generally, the code would be easier to read if line lengths were more limited. E.g. for Blender we have a 120 line length limit. That also makes it easier to have two files open next to each other. Such limits can be enforced automatically with auto-formatters like `autopep8` (what we currently use in Blender) or e.g. `black`.
if not settings.context_brushstrokes: if not settings.context_brushstrokes:
settings.edit_toggle = edit_toggle
return return
if context.object: if context.object:
for i, bs in enumerate(settings.context_brushstrokes): for i, bs in enumerate(settings.context_brushstrokes):
@ -43,6 +47,7 @@ def find_context_brushstrokes(dummy):
settings.active_context_brushstrokes_index = idx settings.active_context_brushstrokes_index = idx
settings.active_context_brushstrokes_index = max(min(settings.active_context_brushstrokes_index, len(settings.context_brushstrokes)-1), 0) settings.active_context_brushstrokes_index = max(min(settings.active_context_brushstrokes_index, len(settings.context_brushstrokes)-1), 0)
settings.edit_toggle = edit_toggle
def update_active_brushstrokes(self, context): def update_active_brushstrokes(self, context):
settings = context.scene.BSBST_settings settings = context.scene.BSBST_settings