Forum: Poser Python Scripting


Subject: How should I read all parameters with keyframes? NextKeyFrame()?

timarender opened this issue on Dec 10, 2013 · 5 posts


timarender posted Tue, 10 December 2013 at 7:05 AM

I would like to access the values of any parameters of Actors which contain keyframes. Andy's Chest, for example includes Twist, Side-Side, Bend, Scale etc.

My slightly ugly code below does NOT work. And I don't understand why not.

Please. Can anyone put me out my misery - how am I supposed to do it?

 

scene = poser.Scene()
scene.SetFrame(0)
figs = scene.Figures()
for fig in figs:
    acts= fig.Actors()
    for actor in acts:
        scene.SelectActor(actor)
        frame = 0
        scene.SetFrame(frame)
        for parm in actor.Parameters():
            frame = 0
            while( frame < scene.NumFrames()-1):
                frame = parm.NextKeyFrame()
            if(not frame):
                 frame = scene.NumFrames()
            else:
                scene.SetFrame(frame)
                print frame, actor.Name(), parm.Name(), parm.Value()


PhilC posted Tue, 10 December 2013 at 8:44 AM

You need to indent:-

if(not frame):

and all the lines below it.


timarender posted Tue, 10 December 2013 at 9:11 AM

Many thanks! I have corrected it and it runs. But oddly, at any keyframe it only finds one paramater for one actor. e.g.

I Load Andy. At frame 11, I set values for his "Chest", for Twist, Side-Side and Bend. When I run the script, it only finds "Twist". And not for the other two parameters.

It feels like Keyframes are attached to the Actor, but don't indicate all the Parameters which may have contributed to being a Keyframe for the Actor.

Hoping I am making sense. And more hopeful that I am missing something obvious.

Thank you.


PhilC posted Tue, 10 December 2013 at 9:29 AM

You need to reset the scene frame to zero at the start of the loop "for parm in actor.Parameters():"


timarender posted Tue, 10 December 2013 at 9:59 AM

Many thanks PhilC! That works perfectly.