1
$\begingroup$

I changed my armature bones and it screwed up my animation. I'd like to traverse ALL my animations and channels and change a specific channel name to the updated bone channel name. How can I do this with their API I cant find docs for traversing the animations.

enter image description here

$\endgroup$
1
$\begingroup$

This should do the trick. Obviously, you will have to fill in the complete dictionary of bone name mappings.

import bpy

d = {"oldname1":"newname1","oldname2":"newname2", }
for action in bpy.data.actions:
    #these so called action groups are the bones, ie one group contains all fcurves of one bone
    for group in action.groups:
        if group.name in d:
            oldname = group.name
            group.name = d[oldname]
            for fcurve in group.channels:
                fcurve.data_path = fcurve.data_path.replace(oldname, d[oldname])
$\endgroup$
  • $\begingroup$ You are a life saver. And here I was thinking the stack exchange was subpar. $\endgroup$ – user3473422 Jan 27 '18 at 20:56

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.