Gathering NLA from armatures?

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
dandeloreon1984
Posts: 0
Joined: Wed Jan 21, 2004 11:12 pm
Contact:

Gathering NLA from armatures?

Post by dandeloreon1984 » Sat Nov 27, 2004 8:48 am

After looking around i found out that you get your animation for armatures from nla, and i would like to ask how i go by getting each action for the armature and it's key frames.

so far i have a simple understanding on how to get keys, but i don't know exactly how it is stored and how to access it.

so far the only example that i can see that is extremely lengthy is the ogre exporter.

der_ton
Posts: 0
Joined: Mon Oct 20, 2003 1:02 am

Post by der_ton » Mon Nov 29, 2004 1:48 am

I learned alot by looking at Jiba's Blender2Cal3D exporter:
http://home.gna.org/oomadness/en/blender2cal3d

dandeloreon1984
Posts: 0
Joined: Wed Jan 21, 2004 11:12 pm
Contact:

Post by dandeloreon1984 » Wed Dec 08, 2004 4:00 am

I understand python about as much as i understand C/C++, and that is very vague and cryptic in what is explained to me, but so far i do know that this is in the bug reports, but this section of code, from Blender2Cal3d is very useful, but it still baffles me and is very very hard for me to understand... oh and do note that this 2nd link right here explains to how i was originally tryin to access animation data.


edit: script was bad... next post is what you want.

dandeloreon1984
Posts: 0
Joined: Wed Jan 21, 2004 11:12 pm
Contact:

Post by dandeloreon1984 » Tue Feb 08, 2005 6:41 pm

to start things off... i hate dobule posting, but i figure since this is now on the second page, i'll post right after myself.

i have figured out how to get the nla informatoin down... but i have few ponderances about it, since i notice that some values that i thought would be there are not....
the only question i reall have is for the action keys and such, why does it not have the readily defined value startframe, and endframe?
( you haft to evaluate the curves of it every time to get that information, thus leading to having too many frames ) ( posible hint on where to get the api a lot better to use )

now for the code... while it is not much, it uses action ipos to get an ipo list and the action names.

Code: Select all

'''
Blender key exporter.... prints them all in the values.
'''
import Blender
from Blender import Registry, Types

for obj in Blender.Object.GetSelected():
	if obj.getType() == "Armature": # I think
		Therig = obj.getData()
		for bo in Therig.bones:
			print "Bonename:",bo.name,""
			SkeletalAnimations = Blender.Armature.NLA.GetActions()
			for SkelAnimKey in SkeletalAnimations.keys():
				print "Action:[",SkelAnimKey,"]"
				print "Skelanimkey_Raw: ", SkelAnimKey
				Ipolist = SkeletalAnimations[SkelAnimKey].getAllChannelIpos()
				print "\t\tCurve: [", Ipolist[bo.name],"]"
				for Testing in Ipolist[bo.name].getCurves():
					Cname = Testing.name
					if (Cname == "LocX"):
						print "\t\tLocation X keyframelist found...",Cname
					if (Cname == "LocY"):
						print "\t\tLocation Y keyframelist found...",Cname
					if (Cname == "LocZ"):
						print "\t\tLocation Z keyframelist found...",Cname

					if (Cname == "QuatX"):
						print "\t\tQuat X keyframelist found...",Cname
					if (Cname == "QuatY"):
						print "\t\tQuat Y keyframelist found...",Cname
					if (Cname ==  "QuatZ"):
						print "\t\tQuat Z keyframelist found...",Cname
					if (Cname ==  "QuatW"):
						print "\t\tQuat W keyframelist found...",Cname

Post Reply