View Full Version : Need MEL expert help!

09 September 2010, 04:38 PM
Iím writing a simple script which should deselect some custom (entered) percentage of selected objects.
It works with 20% selection now:

//Create multiple objects (10 polySpheres for example) and slect them. Run script.
//Do selection
string $currentSelection[] = `ls -selection -flatten`;
//Get a number of items in array
int $NumItems = size($currentSelection);

$cicle = $NumItems*0.8; //Enter a part ofdeselection. Iíll make it worked with entered percent laterÖ
for($i=0;$i<$cicle;++$i) {

$rnd = rand ($NumItems);//random number for selection
int $num = $rnd; //made result integer
$selectedObject = $currentSelection[ $num ];
select -d $selectedObject;


The problem is, that script select more than 20% of objects. I think it happens becouse random number can be the same multiple times. How to avoid this? How to check is this object where deselected or not?

Iím new in MEL, this is my first script actually.
Thank you for help ASAP.

09 September 2010, 05:38 PM
Please don't post the same question on more than one forum. I've already answered your post on the area. It's also here:

CGTalk Moderation
09 September 2010, 05:38 PM
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.