Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Programming (https://simplymaya.com/forum/forumdisplay.php?f=32)
-   -   select random object in selection (https://simplymaya.com/forum/showthread.php?t=31561)

bendingiscool 14-12-2008 11:39 AM

select random object in selection
 
Hey, ok this should be dead simple, but I can't work out the syntax.

Basically I want to be able to be able to select a bunch of geometry, cubes, cylinders, etc, then go through a loop randomly instancing one of them each time through.

So far I have...

string $sel[] = `ls -sl`;

for ($i=0; $i<10; $i++)
{
select $sel[1];
instance;
}

now this is just going to select a specified object from the selection, what I want is to be able to select a random object of the selection each time it loops through.

Many thanks, Chris

t1ck135 16-12-2008 08:45 AM

check out rand() in the documentation
you'll be able to grab a random value in the range of (in your example) 0 to 10 and use that in the select statement

if I had maya installed (learning the slightly cheaper blender at the minute) then I'd modify your code to get it working but you should be able to figure it out easily enough.

Si


All times are GMT. The time now is 02:34 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018