Some Action questions

Hello, I just had some questions about the NLA Action API.

Specifically, I ran into some problems when writing the animation exporter for Neverblender. You can check out nwnmdlexport.py and lib/Animation.py to see what I’ve done so far. Sorry, not very well commented. Not had time to touch the code much :frowning: I left the code a few weeks ago to wait for 2.34, but looks like 2.34 doesn’t help much.

The idea is simple: I need to get orientation and position lists, all along the Action timeline, on keyframes (either based on constant intervals or possibly based on the keyframes on Action).

Anyway, I have this problem: I can figure out what Actions are there in the scene. I can figure out what IPO channels are there in an Action (getAllChannelIpos()).

But how do I find out what objects are animated in Actions, and how?

I get a dictionary of Ipos keyed by Action channel names, which may or may not correspond to Armature Bone names. I can get IpoCurves out of the Ipo, but their names aren’t related in anyway to objects themselves.

I can build a list of Objects in the scene, and the only information I can get from them is that they’re linked to the Armature! The objects are supposed to be linked to individual Bones. How do I get which Bone the Object is linked to - or the other way around? (Armature Bone only knows its children and parent.)

I have this terribly stupid idea of doing this the big, stupid inelegant way - linking the Action, stepping through it and recording each and every object’s location over the course of the animation. Is this the only way to do this?

Did some “thinking” here. Is this Elegant, or is it a Hopelessly Ugly but the Only Way to Do It, or, perhaps, is it Incoherent Rubbish?

(in pseudocode)



    actionlist = list of actions
    armlist = list of armatures
    locdata, oridata = dictionary of (objectname: emptylist)

    foreach action from actionlist:

        length = action.getlength
        othercooldata = action.getothercooldata

        foreach armature from armlist:

            action.setactive(armature)

            foreach object from childrenof(armature):
                step_through_animation(0, length, stride):
                    oridata[object].push(object.getorientation)
                    locdata[object].push(object.getlocation)


Actions are object-indepent armature IPO curve groups. The action contains a group of names. Each name is associated with an IPO. Each name corresponds to a bone name in an armature (any armature). The IPO will then move a bone (with the same name) according its IPO data.

Actions are linked internally to objects not armatures so when an object is of type armature and the armature has appropriately named bones. You can link the action to it and move the object. All objects with armatures can be destroyed and the action will remain because it is object - indepent.