I'm trying to import models from a video game into Blender. The tools I have to dump the models gives me a rigged-but-unanimated FBX as the main model, and a second file in a custom format that contains all the animations. I want to use a script to parse the animation file and create one Action for each animation. However, I'm unable to figure out how from the docs and from tinkering around.
This code works, but inserts the keyframes directly onto the timeline, which isn't what I want:
mybone.rotation_quaternion = some_quaternion_from_file
mybone.keyframe_insert("rotation_quaternion", 1)
Looking at the docs for the keyframe_insert function, it looks like the datapath should be "bones[MyBone].rotation_quaternion", but this doesn't work:
newAction = bpy.data.actions.new("testanim")
bpy.data.objects["Armature"].animation_data.action = newAction
mybone.rotation_quaternion = some_quaternion_from_file
newAction.keyframe_insert("bones[MyBone].rotation_quaternion", 1)
This results in the error "property bones[MyBone].rotation_quaternion not found". I've verified that MyBone exists, and I don't know what exactly it wants for the datapath of keyframe_insert.
What am I doing wrong here? How can I get this to work? I've never used the scripting side of Blender before so I don't really know what I'm doing here.