# evenly space keyframes in dopesheet

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

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

if action:

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

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