Remove cycle modifier using ctrl+clic
1.4.2 - added: `Ctrl + click` on Add cycle modifier remove all cycle on all fcurves (hided option to force clean)master
parent
31ab45865b
commit
dbdba01485
|
@ -1,5 +1,9 @@
|
|||
# Changelog
|
||||
|
||||
1.4.2
|
||||
|
||||
- added: `Ctrl + click` on Add cycle modifier remove all cycle on all fcurves (hided option to force clean)
|
||||
|
||||
1.4.1
|
||||
|
||||
- changed: better filter for applying cycle modifier (prevent targeting prefix-reserved bones)
|
||||
|
|
12
OP_setup.py
12
OP_setup.py
|
@ -75,16 +75,24 @@ class AW_OT_autoset_axis(bpy.types.Operator):
|
|||
class AW_OT_create_cycles_modifiers(bpy.types.Operator):
|
||||
bl_idname = "autowalk.create_cycles_modifiers"
|
||||
bl_label = "Add Cycles Modifiers"
|
||||
bl_description = "Add cycles modifier on all bones not starting with [mch, org, def]\
|
||||
\nand that are non-deforming"
|
||||
bl_description = "Add cycles modifier on all bones not prefixed [mch, org, def, vis,fdl]\
|
||||
\nCtrl + Click : remove ALL Cycles modifiers on all fcurves"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return context.object and context.object.type == 'ARMATURE'
|
||||
|
||||
def invoke(self, context, event):
|
||||
self.ctrl = event.ctrl
|
||||
return self.execute(context)
|
||||
|
||||
def execute(self, context):
|
||||
if self.ctrl:
|
||||
fn.remove_all_cycles_modifier(context.object)
|
||||
else:
|
||||
fn.create_cycle_modifiers(context.object)
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ bl_info = {
|
|||
"name": "Auto Walk",
|
||||
"description": "Develop a walk/run cycles along a curve and pin feets",
|
||||
"author": "Samuel Bernou",
|
||||
"version": (1, 4, 1),
|
||||
"version": (1, 4, 2),
|
||||
"blender": (3, 0, 0),
|
||||
"location": "View3D",
|
||||
"warning": "",
|
||||
|
|
20
fn.py
20
fn.py
|
@ -625,16 +625,22 @@ class attr_set():
|
|||
|
||||
# fcurve modifiers
|
||||
|
||||
def remove_all_cycles_modifier():
|
||||
for fc in bpy.context.object.animation_data.action.fcurves:
|
||||
def remove_all_cycles_modifier(ob=None):
|
||||
ob = ob or bpy.context.object
|
||||
ct = 0
|
||||
for fc in ob.animation_data.action.fcurves:
|
||||
# if fc.data_path.split('"')[1] in selected_names:
|
||||
for m in reversed(fc.modifiers):
|
||||
if m.type == 'CYCLES':
|
||||
ct += 1
|
||||
# print(f'Remove cycle mod on fcurve: {fc.data_path}')
|
||||
fc.modifiers.remove(m)
|
||||
fc.update()
|
||||
print(f'Remove cyclic modifiers on {ct} fcurve(s)')
|
||||
return ct
|
||||
|
||||
def create_cycle_modifiers(ob=None):
|
||||
if not ob:
|
||||
ob = bpy.context.object
|
||||
ob = ob or bpy.context.object
|
||||
|
||||
# skip bones that are on protected layers ?
|
||||
# protected = [i for i, l in enumerate(ob.data.layers_protected) if l]
|
||||
|
@ -646,7 +652,7 @@ def create_cycle_modifiers(ob=None):
|
|||
name_list = [b.name for b in ob.data.bones] # if not b.use_deform (too limiting)
|
||||
|
||||
re_prefix = re.compile(r'^(mch|def|org|vis|fld|ctp)[\._-]', flags=re.I)
|
||||
|
||||
ct = 0
|
||||
for fc in ob.animation_data.action.fcurves:
|
||||
if [m for m in fc.modifiers if m.type == 'CYCLES']:
|
||||
# skip already existing modifier
|
||||
|
@ -665,8 +671,12 @@ def create_cycle_modifiers(ob=None):
|
|||
continue
|
||||
# print(f'Adding cycle modifier {fc.data_path}')
|
||||
_m = fc.modifiers.new(type='CYCLES')
|
||||
ct += 1
|
||||
fc.update()
|
||||
|
||||
print(f'Added cyclic modifiers on {ct} fcurve(s)')
|
||||
return ct
|
||||
|
||||
## Get collection, create if necessary
|
||||
def get_col(name, parent=None, create=True):
|
||||
parent = parent or bpy.context.scene.collection
|
||||
|
|
Loading…
Reference in New Issue