nerd opened this issue on Jul 23, 2010 · 7 posts
nerd posted Fri, 23 July 2010 at 4:02 AM 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
# 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
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