Mon, Dec 2, 11:03 PM CST

Renderosity Forums / Poser - OFFICIAL



Welcome to the Poser - OFFICIAL Forum

Forum Coordinators: RedPhantom

Poser - OFFICIAL F.A.Q (Last Updated: 2024 Dec 02 5:01 am)



Subject: How to randomize prop rotation values?


pitklad ( ) posted Fri, 30 November 2012 at 4:27 AM · edited Sun, 01 December 2024 at 8:45 AM

I want to randomize various props as if those were thrown on air

don't want to move them around just randomize their rotation values

Is there a python script like that?


My FreeStuff


PhilC ( ) posted Fri, 30 November 2012 at 8:05 AM

Apply random rotations to all props in the scene.

import poser
import random

scene = poser.Scene()

def main():
    for actor in scene.Actors():
        # ues try/except to avoid trying to rotating actors that can not.
        try:
            if actor.IsProp():
                print actor.Name()
                actor.ParameterByCode(poser.kParmCodeXROT).SetValue(rnd())
                actor.ParameterByCode(poser.kParmCodeYROT).SetValue(rnd())
                actor.ParameterByCode(poser.kParmCodeZROT).SetValue(rnd())
        except:
            pass

def rnd():
    value = random.uniform(-360,360)
    print "t%f" % value
    return value


main()
scene.DrawAll()
print "done"


pitklad ( ) posted Fri, 30 November 2012 at 6:24 PM

file_489026.png

Thank you so much **PhilC**!

You are the best!

It works great!

Is it possible to make it work on the selected prop only? In case there are other props on the scene?


My FreeStuff


markschum ( ) posted Fri, 30 November 2012 at 6:47 PM

the line  "for actor in scene.Actors():" is going to go through every prop, light, camera etxc in the scene.

def main():<br></br><br></br>       actor = scene.CurrentActor()<br></br><br></br>        # ues try/except to avoid trying to rotating actors that can not.<br></br><br></br>        try:<br></br><br></br>            if actor.IsProp():<br></br><br></br>                print actor.Name()<br></br><br></br>                actor.ParameterByCode(poser.kParmCodeXROT).SetValue(rnd())<br></br><br></br>                actor.ParameterByCode(poser.kParmCodeYROT).SetValue(rnd())<br></br><br></br>                actor.ParameterByCode(poser.kParmCodeZROT).SetValue(rnd())<br></br><br></br>        except:<br></br><br></br>            pass<br></br><br></br>make the change and get the indentations right and it will do only the selected actor (prop)<br></br><br></br><br></br>


pitklad ( ) posted Fri, 30 November 2012 at 7:13 PM

Perfection! Thank you markschum!

Python seams like magic to me, I assumed the spell should be changed a little to work :biggrin:


My FreeStuff


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.