Thu, Jan 2, 11:18 PM CST

Renderosity Forums / Poser Python Scripting



Welcome to the Poser Python Scripting Forum

Forum Moderators: Staff

Poser Python Scripting F.A.Q (Last Updated: 2024 Dec 02 3:16 pm)

We now have a ProPack Section in the Poser FreeStuff.
Check out the new Poser Python Wish List thread. If you have an idea for a script, jot it down and maybe someone can write it. If you're looking to write a script, check out this thread for useful suggestions.

Also, check out the official Python site for interpreters, sample code, applications, cool links and debuggers. This is THE central site for Python.

You can now attach text files to your posts to pass around scripts. Just attach the script as a txt file like you would a jpg or gif. Since the forum will use a random name for the file in the link, you should give instructions on what the file name should be and where to install it. Its a good idea to usually put that info right in the script file as well.

Checkout the Renderosity MarketPlace - Your source for digital art content!



Subject: Script to randomize a dial


nerd ( ) posted Fri, 23 July 2010 at 4:02 AM · edited Thu, 02 January 2025 at 11:15 PM
Forum Moderator

Before I went reinventing this particular wheel I though I'd check to see if somebody had already done it.

I need to randomize the value of a particular dial that is in a bunch of body parts. Basically creating (psudo)random movements. Just changing each instance or the "random" dial to a random number.


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>


Lucifer_The_Dark ( ) posted Fri, 23 July 2010 at 5:28 AM · edited Fri, 23 July 2010 at 5:29 AM

Semidieu has the Advanced Figure Randomizer over at RDNA & I think there might be a free one here as well, ockham would be a good person to start your search with.

Then of course PhilC might be persuaded to pop in with the exact thing you're after written in seconds. hehehe :thumbupboth:

Windows 7 64Bit
Poser Pro 2010 SR1


PhilC ( ) posted Fri, 23 July 2010 at 5:32 AM

random.random() will generate a random number between 0.000 and 1.000 however there are other ways to generate a random number which you may want to play with.
random.randint(a,b)

This will produce a random integer N such that a <= N <= b.

Just play around with it :)

Hope that helps.


PhilC ( ) posted Fri, 23 July 2010 at 5:32 AM

pop :)


nerd ( ) posted Fri, 23 July 2010 at 5:43 AM
Forum Moderator

See I just knew that wheel had already been invented. Thanks! This will make my life much easier.


Lucifer_The_Dark ( ) posted Fri, 23 July 2010 at 7:38 AM

Quote - pop :)

:lol:

Windows 7 64Bit
Poser Pro 2010 SR1


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.