I want to do an animation of the motion of an horse. Now i moved single keyframes because i had some in wrong order. But now they arent evenly spaced, and it shows :)

If somone knows how i could achieve this automatically I would be extremely happy

enter image description here


Helper Script

For each fcurve in the context object's action, space keyframes evenly based on start, end frame and how many keyframes.

import bpy
context = bpy.context
ob = context.object
ad = ob.animation_data
action = ad.action if ad else None

if action:

    fs, fend = action.frame_range
    flength = fend - fs            
    for fc in action.fcurves:            
        N = len(fc.keyframe_points) 
        if N < 2:
        df = flength / (N - 1)

        for i, kfp in enumerate(fc.keyframe_points):
            kfp.co.x = fs + i * df

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.