5
$\begingroup$

I want to copy the world positions of a first bone to a second bone then save the second bones position as a keyframe(when the first bone has a keyframe) to retroactively fix rigging errors with roll on ik bones.

I can't sample the fcurves as they are local space so instead want to iterate the actions and set the frame then grab the matrix to apply and keyframe the second bone but can't find the command to set the action.

$\endgroup$
11
$\begingroup$

All actions in the file are saved in bpy.data.actions

for a in bpy.data.actions:
    print(a.name)

The action associated directly with your object, the one I'd call "in the slot"

action = object.animation_data.action

To set it to another action named "anotheraction"

object.animation_data.action = bpy.data.actions.get("anotheraction")

If there is no action named anotheraction it will set it to None. If there is no animation data on the object you will need to call

object.animation_data_create()

beforehand.

Note: can also have actions on any strip in the strips collection of an nla track in the animation_data.nla_tracks collection of your object.

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ Another hint for whoever is trying to set this at the armature: you set it actually at the object, not the armature. $\endgroup$ – jsbueno Apr 6 '18 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.