script: Randomize Rotation ( by jms )

Say i had a bunch of objects with the exact same rotation, and I wanted to mess them up a bit. I mention this because it’s seems useful, and I would guess, simple to accomplish.

import Blender
from Blender import Noise,Object

#select the objects you want to rotate 
OBJECTS=Object.GetSelected()

Nr=Noise.random
for Obj in OBJECTS:
      E=Obj.getEuler()
      print E
      Obj.setEuler([Obj.getEuler()[0]+Nr(),
      Obj.getEuler()[1]+Nr(),
      Obj.getEuler()[2]+Nr()])

I’m getting an error in line 2,… Import error: cannot import name Noise

Curious. Under win98, it works with blender 2.33.

It just occured to me that it was because i am using 2.32. :expressionless:
Time to go get a fresh Python install.
<edit> just curious, is this utilizing internal blender python, or is it a full install thingy?

Just Blender 2.33 internal python module and Classes. If you have a full python 2.2.3 installed with blender 2.32:

import Blender
from Blender import Object
import random

OBJECTS=Object.GetSelected()
Nr=random.Random()

for Obj in OBJECTS:
      Obj.setEuler([Obj.getEuler()[0]+Nr.random(),
                    Obj.getEuler()[1]+Nr.random(),
                    Obj.getEuler()[2]+Nr.random()])
Blender.Redraw()

Ok, it appears to be running smoothly now. Thanks a million jms.

http://home.att.net/~moton-toybox/randomrot.jpg