10
$\begingroup$

Is there a way to move a keyframe using Python (change the frame at which the keyframe is set)?

The keyframe already exists. I need to access it and move it, with the script.

$\endgroup$

1 Answer 1

15
$\begingroup$

This is not hard:

bpy.data.actions[aname].fcurves[i].keyframe_points[j].co[0] = fr1

The tricky part is picking the right fcurve[i] and keyframe_points[j] if there are more than one. You'll have to check fcurve[i].data_path and (if it's a vector data_path like location or rotation*) fcurve[i].array_index to make sure you're altering the right fcurve.

$\endgroup$
1
  • 4
    $\begingroup$ You can also access co[0] and co[1] like co.x (frame) and co.y (value). The action associated with an object is accessible via Object.animation_data.action. Note that both animation_data and action can be None. $\endgroup$
    – CodeManX
    Commented Jan 28, 2015 at 17:34

You must log in to answer this question.

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