Message 1 of 11
Need help from MEL experts!

Not applicable
09-18-2010
09:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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;
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.
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;
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.