From d77ab84c06614d20a15cc51dee90c18fd46b5be5 Mon Sep 17 00:00:00 2001 From: Pullusb Date: Fri, 1 Apr 2022 12:12:05 +0200 Subject: [PATCH] update fcurve after bake --- OP_expand_cycle_step.py | 14 +++++++------- OP_setup_curve_path.py | 4 ++-- README.md | 4 ++++ __init__.py | 2 +- fn.py | 17 ++++++++++++++++- 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/OP_expand_cycle_step.py b/OP_expand_cycle_step.py index 1e1840a..52ad961 100644 --- a/OP_expand_cycle_step.py +++ b/OP_expand_cycle_step.py @@ -8,7 +8,6 @@ from time import time def bake_cycle(on_selection=True): print(fn.helper()) debug = fn.get_addon_prefs().debug - print('debug: ', debug) obj = bpy.context.object if obj.type != 'ARMATURE': print('ERROR', 'active is not an armature type') @@ -120,12 +119,15 @@ def bake_cycle(on_selection=True): if not ct: return ('ERROR', 'No fcurve treated (! action duplicated to _expand !)') + # cleaning update + fn.update_action(act) print('end of anim cycle keys baking') # C.scene.frame_current = org_frame # detect last key in contact def step_path(): + '''Step the path anim of the curve to constant''' print(fn.helper()) obj = bpy.context.object @@ -140,7 +142,7 @@ def step_path(): act = fn.get_obj_action(obj) if not act: return - # CHANGE - retiré le int de la frame + # CHANGE - removed int from frame # keyframes = [int(k.co[0]) for fcu in act.fcurves for k in fcu.keyframe_points] keyframes = [k.co[0] for fcu in act.fcurves for k in fcu.keyframe_points] keyframes = list(set(keyframes)) @@ -175,9 +177,10 @@ def step_path(): for k in t_fcu.keyframe_points: k.interpolation = 'CONSTANT' + # cleaning update (might not be needed here) + fn.update_action(act) print('end of step_anim') - class UAC_OT_bake_cycle_and_step(bpy.types.Operator): bl_idname = "anim.bake_cycle_and_step" bl_label = "Bake key and step path " @@ -218,10 +221,7 @@ class UAC_OT_bake_cycle_and_step(bpy.types.Operator): for k in timef.keyframe_points: k.interpolation = 'LINEAR' print(f'Anim path to linear : Deleted all keys ({keys_ct - 2}) on anim path except first and last') - - - - + # CHAINED ACTION pin feet ?? : Step the path of the curve path return {"FINISHED"} diff --git a/OP_setup_curve_path.py b/OP_setup_curve_path.py index 2fe211c..171962a 100644 --- a/OP_setup_curve_path.py +++ b/OP_setup_curve_path.py @@ -158,7 +158,7 @@ class UAC_OT_create_curve_path(bpy.types.Operator): class UAC_OT_create_follow_path(bpy.types.Operator): bl_idname = "anim.create_follow_path" - bl_label = "Create follow path constraint" + bl_label = "Create Follow Path Constraint" bl_description = "Create follow path targeting curve in field" bl_options = {"REGISTER", "UNDO"} @@ -178,7 +178,7 @@ class UAC_OT_create_follow_path(bpy.types.Operator): class UAC_OT_snap_curve_to_ground(bpy.types.Operator): bl_idname = "anim.snap_curve_to_ground" bl_label = "snap_curve_to_ground" - bl_description = "snap curve" + bl_description = "Snap Curve" bl_options = {"REGISTER", "UNDO"} @classmethod diff --git a/README.md b/README.md index 8e01ce9..8d6761b 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,10 @@ Sidebar > Anim > unfold anim cycle ## Changelog: +0.4.1 + +- update fcurve after bake + 0.4.0 - better curve creation diff --git a/__init__.py b/__init__.py index 045fb70..ee15559 100644 --- a/__init__.py +++ b/__init__.py @@ -2,7 +2,7 @@ bl_info = { "name": "Unfold Anim Cycle", "description": "Anim tools to develop walk/run cycles along a curve", "author": "Samuel Bernou", - "version": (0, 4, 0), + "version": (0, 4, 1), "blender": (3, 0, 0), "location": "View3D", "warning": "WIP", diff --git a/fn.py b/fn.py index 5ef78c2..b4acc4a 100644 --- a/fn.py +++ b/fn.py @@ -296,4 +296,19 @@ def generate_curve(location=(0,0,0), direction=(1,0,0), name='curve_path', enter context.space_data.overlay.show_curve_normals = True context.space_data.overlay.normals_length = 0.2 - return curve \ No newline at end of file + return curve + +def update_action(act): + '''update fcurves (often broken after generation through API)''' + + # update fcurves + for fcu in act.fcurves: + fcu.update() + + # redraw graph area + for window in bpy.context.window_manager.windows: + screen = window.screen + for area in screen.areas: + if area.type == 'GRAPH_EDITOR': + area.tag_redraw() +