My script below should be straightforward for you. I export the bones, then I export the posed bones for each frame. I want to however export using keyframes. I’ve looked at NLA and actions but nothing works and I see nothing that designates a function returning what bones have what keyframes. How do I get this data? I only want to export a pose Bone matrix if that specific bone has a keyframe at a given frame in my timeline.
anim_File = file(Objects_Name + ".txt" ,"w")
render.currentFrame(1)
last_frame = render.endFrame()
last_frame = last_frame + 1
armature = ob.getData()
arm_bones = armature.bones.values()
#write how many bones and how many frames for this animation
num_bones = 0
for bone in arm_bones:
num_bones = num_bones + 1
anim_File.write("%i " % num_bones)
num_frame = last_frame
anim_File.write("%i
" % last_frame)
#export each bone parent and bind matrix
for bone in arm_bones:
anim_File.write( bone.name + " ")
Parent = bone.parent
if( Parent ):
anim_File.write(Parent.name + "
")
else:
anim_File.write(“NULL” + "
")
anim_File.write( "%s
" % bone.matrix)
Pose = ob.getPose()
Bones = Pose.bones.values()
#export each pose frame
for bone in Bones:
anim_File.write( bone.name + "
")
for i in range(1, last_frame):
render.currentFrame(i)
anim_File.write("%s
" % (bone.poseMatrix) )
anim_File.close()