PDA

View Full Version : Need MEL expert help!


vijai3d
09-18-2010, 05: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.

mduvekot
09-18-2010, 06: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: http://www.thnkr.com/wiki/index.php?title=How_to_randomly_select_80%25_of_the_currently_selected_objects

CGTalk Moderation
09-18-2010, 06: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.