Forum: Poser Python Scripting


Subject: Script to randomize a dial

nerd opened this issue on Jul 23, 2010 · 7 posts


PhilC posted Fri, 23 July 2010 at 5:27 AM

Script to set random value on named dial

# Written by PhilC<br></br>
# <a href="http://www.philc.net">http://www.philc.net</a><br></br>
# Use at your own risk

#------------------------<br></br>
# Start user edit

# Set name of dial here. (Use external name)<br></br>
dialName = "twist"

# Random number will be a floating point number between
one and zero.<br></br>
# Multiply this by a factor if higher or lower values are
required.<br></br>
# Note that factor may be negative.<br></br>
factor = 20

# End user edit<br></br>
#------------------------

import poser<br></br>
import random<br></br>
import string

scene = poser.Scene()

# make all lower case<br></br>
dialName = string.lower(dialName)

def main():<br></br>
    fig = scene.CurrentFigure()<br></br>
    if not fig:<br></br>
        print "Please
select a figure."<br></br>
        return<br></br>
    for actor in fig.Actors():<br></br>
        for parm in
actor.Parameters():<br></br>
           
if string.lower(parm.Name()) == dialName:<br></br>
               
dialValue = random.random() * factor<br></br>
               
parm.SetValue(dialValue)<br></br>
               <br></br>
main()<br></br>
scene.DrawAll()<br></br>