I have this cube animation that moves at Z axis from Frame 1 to Frame 48.
I am trying to select a particular fcurve (Z location in this case) and trying to move a single keyframe from Frame 48 to Frame 62
import bpy
# Configuration
action_name = 'CubeAction'
data_path = 'location'
index = 2 # Z axis
# Find the appropriate action
action = bpy.data.actions.get(action_name)
if action:
# From this action, retrieve the appropriate F-Curve
fcurve = action.fcurves.find(data_path = data_path, index = index)
if fcurve:
for index in range(48, 63):
fcurve.keyframe_points[index] += 2
But I am receiving an error below, what am I doing wrong?
Array iterator out of range: FCurve_keyframe_points_lookup_int (index 48)
Traceback (most recent call last):
File "/Keyframe_mover.py", line 16, in <module>
IndexError: bpy_prop_collection[index]: index 48 out of range, size 2
Error: Python script failed, check the message in the system console