View Full Version : random rotation

12 December 2010, 10:08 AM
can anyone tell me how to give random rotation to objects with script i have more than 600 objects

12 December 2010, 10:23 AM
This should do the trick :)
//Get selected objects
$selObj = `ls -sl`;
//For each object
for($sel in $selObj)
//Generate a random number between -360 to 360
$randX = `rand -360 360`;
$randY = `rand -360 360`;
$randZ = `rand -360 360`;
//Rotate the current object to the random values
rotate -r -os $randX $randY $randZ $sel;

12 December 2010, 10:56 AM
hi ur script is great and working fine can u tell me how to give random values in bend
deform because set attr is about confusing but setting transform random value your
script is great thanks a lot

12 December 2010, 01:24 PM
how to give random values in bend deform because set attr is about confusing
I'm not sure if I understand exactly what you're asking here.

Setting random values to bend deformers is pretty similar, it's just that you use the setAttr instead.

//Generate a random number
$rand = `rand -2 2`;
//Set the curvature of bend1 to $rand
setAttr "bend1.curvature" $rand;

12 December 2010, 02:06 PM
Hey Jørn, I assume he has the same problem as before, in that he doesn't know how to apply a setAttr (randomly) to a whole bunch of bends (600+?)
something like:
//Get ALL bends
string $allBends[] = `ls -type "nonLinear"`;
//For each bend
for($bend in $allBends)
// Generate a random number between -3.14 and 3.14
float $rand = `rand -3.14 3.14`;
// edit the curvature attribute:
setAttr ($bend+".curvature") $rand;

12 December 2010, 04:42 AM
hi guys i am very thankful for your support i hope in future u will be helping me out in mel and scripts

CGTalk Moderation
12 December 2010, 04:42 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.