I am looking for a way to copy all keyframes from Action A to Action B with time offset X using python.

Any ideas?


1 Answer 1


Here is a script that copies actionA (hardcoded to "CubeAction", change to suit) to actionB and adds a frame offset to each key.

import bpy
# change how action is picked
# actionA = bpy.context.object.animation_data.action
actionA = bpy.data.actions.get("CubeAction")
if actionA is not None:
    # copy the action
    actionB = actionA.copy()
    offset = 10 # frames
    # iter thru fcurves and move keyframes by offset
    for fc in actionB.fcurves:
        for kf in fc.keyframe_points:
            kf.co.x += offset

Note this can also be done pretty simply in the NLA, by moving an action strip to the desired frame start. This way you can keep all your actions as starting at frame 1.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .