Forum: Poser - OFFICIAL


Subject: How to randomize prop rotation values?

pitklad opened this issue on Nov 30, 2012 ยท 5 posts


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"