Forum: Poser - OFFICIAL


Subject: Great Found 600 free BHV motions(Poser) in case you haven't

tebop opened this issue on Oct 30, 2007 · 56 posts


diolma posted Sun, 04 November 2007 at 4:33 PM

#-----------------------------------------------------------------------------

Spread param changes between chest and abdomen

Copyright (c) 2007 John Avery (Diolma)

4th Nov 2007

Figure must be selected for the script to run properly.

All key-frame rotations for the chest will be spread between abd. and chest (50/50)

It is not advisable to run this script twice on the same figure in the same scene!

#-----------------------------------------------------------------------------

from Tkinter import *
import poser
scene = poser.Scene()

#-----------------------------------------------------------------------------

Next section is TK

#------------------------------------------------------------

class App:
   
    # - - - - - - - - - - - - - - - - - -
    def init(self, master, textMessage):
        self.master = master
        master.title("Share Rotations")

        self.StatusEntry = Entry(self.master,width=50)
        self.StatusEntry.grid(row=0,column=0,columnspan=2) # columnspan = 3 if debugging..
        self.StatusEntry.insert(0,"Select the figure then click GO")
       
        # Go/nogo buttons.
        self.buttonGo = Button(self.master, text="GO", command=self.doGo)
        self.buttonGo.grid(row=3, column=0)

        self.buttonCancel = Button(self.master, text="Cancel", command=self.doCancel)
        self.buttonCancel.grid(row=3, column=1)

        self.master.protocol('WM_DELETE_WINDOW', self.doCancel)
       
    # - - - - - - - - - - - - - - - - - -
    def ShowStatus(self,S): # Just saving repetition
        self.StatusEntry.delete(0,END)
        self.StatusEntry.insert(0,S)
        self.StatusEntry.update_idletasks()

    # - - - - - - - - - - - - - - - - - -
    def Update(self):
        if scene: scene.ProcessSomeEvents(1)
        root.lift()
        root.after(100, self.Update)

    # - - - - - - - - - - - - - - - - - -
    def doGo(self):
       
        # - Sanity check...
        try:
            Figure = scene.CurrentFigure()
            aChest = Figure.Actor( "Chest" )
            aAbdomen = Figure.Actor( "Abdomen" )
        except:
            if not Figure:
                self.ShowStatus( "No figure selected" )
            else:
                self.ShowStatus( "%s: Chest or Abdomen missing!" % Figure.Name() )
            return
                        
        # - OK, do it.
        self.ShowStatus( "Running..." )
        self.doActor( aChest, aAbdomen )

        scene.SetFrame(0)
        self.master.destroy()

    # - - - - - - - - - - - - - - - - - -
    def doCancel(self):
        self.master.destroy()
       
    # - - - - - - - - - - - - - - - - - -
    def doActor( self, aChest, aAbdomen ):
        ## -- For some reason I still don't understand, the "Twist" values weren't working when
called with name = "Twist"
        ## -- ("Bend" and "Side-Side" worked OK, just not "Twist").
        ## -- So I tried the "ByCode" method - that seemed OK...
       
        chestXR = aChest.ParameterByCode(poser.kParmCodeXROT ) #Bend
        chestYR = aChest.ParameterByCode(poser.kParmCodeYROT ) #Twist
        chestZR = aChest.ParameterByCode(poser.kParmCodeZROT ) #Side-Side
           
        abdXR = aAbdomen.ParameterByCode(poser.kParmCodeXROT )
        abdYR = aAbdomen.ParameterByCode(poser.kParmCodeYROT )
        abdZR = aAbdomen.ParameterByCode(poser.kParmCodeZROT )
                                      
        F=0                         # Init Frame number
        while 1:                    # Forever (except we'll break out eventually)
            scene.SetFrame(F)
            # Comment out the next line to speed things up..
            self.ShowStatus( "Frame: %d" % F )

            # Deal with this frame
            v = (abdXR.Value() + chestXR.Value()) * 0.5
            abdXR.SetValue( v )
            chestXR.SetValue( v )
           
            v = (abdYR.Value() + chestYR.Value()) * 0.5
            abdYR.SetValue( v )
            chestYR.SetValue( v )
                                      
            v = (abdZR.Value() + chestZR.Value()) * 0.5
            abdZR.SetValue( v )
            chestZR.SetValue( v )
                                      
            F = aChest.NextKeyFrame() # Next..
                                      
            if not F: break         # No more - break out of the loop.
        # End while 1

#------------------------------------------------------------

Activate the loop

#------------------------------------------------------------

root = Tk()
app = App(root, '')
app.Update()
root.mainloop()

#------------------------------------------------------------

End TK loop.

#-----------------------------------------------------------------------------