change frame of a key

hi,

In first i apologize if my english is realy bad ^^’

I’m new in the python scripting and i want to change the frame of a key by script to have a thing like that :

http://image.noelshack.com/minis/2014/15/1397384563-capture.png

And i want to do it for all keys but not the first.

Any ideas?

Thanks,
Sparadrax :smiley:

You need to find the right keyframe in the action’s fcurve and change its x coordinate:

import bpy

ob = bpy.context.object

if (ob is not None and
    ob.animation_data is not None and
    ob.animation_data.action is not None):
    
    for fcurve in ob.animation_data.action.fcurves:
        # grab location.z curve
        if fcurve.data_path == "location" and fcurve.array_index = 2:
            for k in fcurve.keyframe_points:
                # find keyframe at frame 60 and move
                if k.co.x == 60:
                    k.co.x = 77
                    break