QUOTE
The problem I have with selectType is that the default behavior isn't always going to turn off the unwanted masks, so there will be times when you're selecting edges and the vert selectType is still turned on. Have you not experienced this problem?
You cant have problem with select type because if you do you cant change selection type.Well i just do what the asker wanted (he wanted the same behavior as rmb button i gave it to him). Anyway ive accounted for that its why i call:
selectType -ocm -alc false;
this clears the selection mask, this way i never have this problem. But alas theres a problem the modes in the status bar always superceeds what you've set (theres 2 modes global and object). It would even apply to the original code. This si very deliberate as thats the behavior he asked for. however were you to change the code to:
CODE
hilite ls -sl
;
selectMode -component;
selectType -alc false;
selectType
-controlVertex 1
-vertex 1
-subdivMeshPoint 1
without the ocm. it would change the global mask and keep the selection. Wich s closer to what combustible wants, and garnted mimics the f keys better without clearing mask. Then just unlioad the other selections if you want.
rgkovach: yes its a bit heavy. Actually max does store the selection per context. Anyway i do have a suggestion for you. instead of using
global string $vertSel[];
for selection keeping do keep the selection is a quick selection set instead thisway your less likely to clash later.
it would also simplify your code quite significantly as you could do off withe the if else and case closures. so you'd end up with:
CODE
sets -clear $mode;
sets -add $mode ls -sl
;
Besides thsi would let you mine selections as accurately as you want even on per object basis.
PS building on this ist posssible to retrieve the selections that caused the hiostory objects to do something and rolling back history JUST like in max too.
PPS: even if the mel codes shipped have often a switch jsut to change one flag in mel you dont need its possible to pass a flag to a swicch withe the alternale form code so you can have:
$flag="-sl";
print (ls($flag));
so if you evere see something like:
CODE
switch( $mode ) { case "hierarchical":
selectionMaskRestoreOnce();
selectMode -hierarchical;
break;
case "root":
selectionMaskRestoreOnce();
selectMode -root;
break;
case "leaf":
selectionMaskRestoreOnce();
selectMode -leaf;
break;
case "template":
selectionMaskRestoreOnce();
selectMode -template;
break;
case "object":
selectionMaskRestoreOnce();
selectMode -object;
break;
case "component":
selectionMaskRestoreOnce();
selectMode -component;
break;
}
youd KNOW its not a mel coder who did it. but a c coder. as they could have as easily written:
CODE
selectionMaskRestoreOnce();
selectMode("-"+$mode);