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")
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
" % 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 + "
anim_File.write(“NULL” + "
" % 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):
" % (bone.poseMatrix) )
Upon more investigation I have found all the keyframes, but I dont know how to determine which bone(s) have a keyframe on the frame.
action=actions.get(“Action”)#hard-coded action name
i accessed the fcurve colors with this:
dirty-stick: adam450 is obviously using Blender 2.4x, so 2.5+ API won’t help him
Even then his code only gives me the curve points. It does not give me any information regarding what bones have a keyframe at this point.
Nvm. Sweet I guess I can continue using blender 2.4 since I love it so much and just load my file into 2.6 to output it: The solution:
objects = bpy.context.selected_objects
object = objects
animData = object.animation_data
action = animData.action
bone = action.groups #action.groups is the bone data seen in the dope sheet
#print bone.name and you will see the name of the bone(s)
#each bone has 10 channels, ipo curves for x,y,z,w rotation x,y,z position x,y,z scale
for channel in bone.channels:
#find all frames that have a key for this channel (osition/rotation/scale attribute)
Now that I found the newer documentation and got that, I figured out what the heck blender is doing in 2.4. Here is the script as well:
action = ob.getAction() #NLA Action
channels = action.getAllChannelIpos()#bones = channels, 1 channel for each bone
for channel in channels:
ipo = action.getChannelIpo(channel)#get the ipo data for this bone
curves = ipo.getCurves()#get the physical 3d curve(s) you see in the ipo editor
for curve in curves: #there are 10 curves, position "x,y,z" rotation "x,y,z,w" scale "x,y,z"
points = curve.getPoints() #3d point, x axis corresponds to frame in the ipo editor
for point in points: