Mon, Jan 20, 3:49 PM CST

Renderosity Forums / Poser - OFFICIAL



Welcome to the Poser - OFFICIAL Forum

Forum Coordinators: RedPhantom

Poser - OFFICIAL F.A.Q (Last Updated: 2025 Jan 20 11:41 am)



Subject: python keyframes ..


cortic ( ) posted Sun, 10 February 2013 at 2:43 AM · edited Sun, 19 January 2025 at 12:12 PM

has anyone made a script to add / remove keyframes from pre-selected body parts?  every few frames I have to add keyframes to hip, hands, feet, head, hair.  all manually, one at a time, I would like to create a script to remember which parts I’ve put keyframes on in that animation and generate a button to set keyframes for all those body parts in current frame.

 

just wondering if its been done before, I’ve searched but can't find anything ..

 

thanks.


PhilC ( ) posted Sun, 10 February 2013 at 4:43 AM

To understand your need better may I please ask why you want to add so many key frames?


cortic ( ) posted Sun, 10 February 2013 at 5:20 AM

if a hand grasps something in frame 20, but doesn’t change (x,y,z) until frame 40, and no key frame was put in frame 20 then there would be an ark of movement from frame 0 - 40 and a grasp at mid air somewhere -this is the basic problem I have when animating, I solve it by adding keyframes to the main body parts at every 'key' point in an animation.  This locks down movement points and seems to reduce the need for error correction..


ockham ( ) posted Sun, 10 February 2013 at 6:02 AM

Attached Link: Set Range

file_491497.jpg

The cure is probably to set parts of the timeline to linear, rather than adding lots of keys.  You can do this in the animation controls, which are clumsy and hard to use.

Or you might try my little script that sets the current actor or figure to linear or spline, before or after the current keyframe.  It's in the ZIP linked above.

Or you could use this simple code to keyframe the whole timeline for the current actor.   I use this a lot in short animations. 

import poser
scene = poser.Scene()
TheActor = scene.CurrentActor()

Run a loop across frames.

for i in range(0,scene.NumFrames()):
  scene.SetFrame(i)
  TheActor.AddKeyFrame(i)  # force keyframes

If you want to keyframe only every 3rd frame,

 

import poser
scene = poser.Scene()
TheActor = scene.CurrentActor()

Run a loop across frames.

for i in range(0,scene.NumFrames(),3): # every third frame
  scene.SetFrame(i)
  TheActor.AddKeyFrame(i)  # force keyframes

 

And so on.....

 

My python page
My ShareCG freebies


cortic ( ) posted Sun, 10 February 2013 at 6:17 AM

ockham - thanks, I already have your script, and it is such a time saver for things like flapping wings or really fast animations, its not really what I’m after here though.  sometimes its good to keep the spline curve for smoother movements. And my key frames are not generally the same number of frames apart so setting a set amount wouldn’t help. 


PhilC ( ) posted Sun, 10 February 2013 at 6:50 AM

Put a spline break at frames 20 and 40. This video tutorial will explain why.

http://www.philc.net/animation1.php


cortic ( ) posted Sun, 10 February 2013 at 8:23 AM

PhilC – thanks, I know about spline break and use it in error correction often, but there does have to be a keyframe there first.  And in order to make a keyframe I have to click on the body objects and then click on the 'add keyframe' button.  Two hands two feet, hip, neck, head, hair etc, every 20 - 10 frames, that’s 16+ clicks every 20 frames that could be contained in one click of a python script -which is what I’m trying to create, I was just wondering if someone else did anything similar cause I don't want to repeat someone else’s work.

 


markschum ( ) posted Sun, 10 February 2013 at 12:11 PM

why dont you change the setting so adding a keyframe adds a keyframe for everything. I believe thats a checkbox on the animation timeline panel.

 


cortic ( ) posted Sun, 10 February 2013 at 12:34 PM

I can select 'all elements' in the animation pallet and it does keyframe everything within a character but I'd still like some things left alone, e.g. wings, or even fingers, I animate the body then go back and do the fiddly bits - if keyframes have been put into them then I have to select and delete the key frames (which isn't so bad for one set, but becomes a pain for multiple props with multiple parts and articulated digits)..

 

I guess there isn't a script that can do what I'm after here, I'll get started on making one, thanks everyone for your help :)


cortic ( ) posted Sun, 10 February 2013 at 8:30 PM

file_491515.jpg

finished a basic script for this, got a weird problem, the animation palette is not updating properly until I exit the python window.  Attached a pic to show the problem, key frames are being added to the sub-properties but the actor / group they are in (in this case hip) is not updating until I close the python window.


cortic ( ) posted Sun, 10 February 2013 at 8:33 PM

here is the script, messy i know, but i think it should work;

import poser
scene=poser.Scene()
from Tkinter import *
listbox = []

class App:
    def init(self, master):
        global listbox
        frame = Frame(master)
        frame.pack()
        self.kl_me = Button(frame, text="X", command=self.kill_ths, width=1, height=6)
        self.kl_me.pack(side=LEFT)
        scrollbar = Scrollbar(frame, orient=VERTICAL)
        listbox = Listbox(frame, yscrollcommand=scrollbar.set, width=12, height=6)
        scrollbar.config(command=listbox.yview)
        scrollbar.pack(side=RIGHT, fill=Y)
        listbox.pack(side=LEFT, fill=BOTH, expand=1)
        self.ad_me = Button(frame, text="<ADD", command=self.add_ths, width=6, height=3)
        self.ad_me.pack(side=TOP)
        self.key_me = Button(frame, text="<KeY", command=self.key_ths, width=6, height=3)
        self.key_me.pack(side=TOP)

    def add_ths(self):
        global listbox
        TheActor = scene.CurrentActor().InternalName()
        listbox.insert(END, TheActor)

    def kill_ths(self):
        global listbox
        listbox.delete(0, END)

    def key_ths(self):
        global listbox
        for i in range(0,listbox.size()):
            jobo = listbox.get(i)
            TheActor = scene.ActorByInternalName(jobo)
            TheActor.AddKeyFrame()

root = Tk()
app = App(root)
root.wm_attributes("-topmost", 1)
root.mainloop()


cortic ( ) posted Mon, 11 February 2013 at 1:37 AM

ockham - i have the same problem when your script is open, can't add key frames manually without this bug, closing and opening the animation palette doesn't help.. looks like a bug in pro 2010.


Privacy Notice

This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.