1
$\begingroup$

I want to offset the keyframes on a specific action. I found this script which does something similar to what I want, but it offsets the keyframes on every action in the scene:

arm_action = bpy.data.actions

for action in arm_action:
    for fcurve in action.fcurves:
        for point in fcurve.keyframe_points:
            point.co.x -= 50

I'm trying to directly refer to the action that I want to offset with the line:

arm_action = bpy.context.scene.objects['Armature'].animation_data.action

But I got the following error: 'Action' object is not iterable

$\endgroup$

2 Answers 2

2
$\begingroup$

try this:

import bpy

arm_action = bpy.data.actions['ArmatureAction']



for fcurve in arm_action.fcurves:
    for point in fcurve.keyframe_points:
        point.co.x += 10
$\endgroup$
2
  • $\begingroup$ hey sorry bro we answered at the same time but i noticed you got it first XD $\endgroup$ Jul 6, 2022 at 11:08
  • 1
    $\begingroup$ no problem, that's life ;) no need to say sorry. And i have enough reputation...it's good if the "young ones" got some points ;) $\endgroup$
    – Chris
    Jul 6, 2022 at 11:09
1
$\begingroup$

Yes ofcourse. That is because bpy.context.scene.objects['Armature'].animation_data.action is not a list of objects. You can also see that the ending is .action and is singular not plural. It's only a single object and you can't iterate on a single object.

Just omit the first for loop:

arm_action = bpy.context.scene.objects['Armature'].animation_data.action
action = arm_action

for fcurve in action.fcurves:
    for point in fcurve.keyframe_points:
        point.co.x -= 50
$\endgroup$

You must log in to answer this question.

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