PDA

View Full Version : getting object selection mode using mel


DEVILSAN
02-07-2009, 01:37 AM
Hi I was trying to figure out how to get what mode i am in using MEL so i found this procedure at this place C:/Program Files/Autodesk/Maya2008/scripts/others/dagMenuProc.mel
i never came to learn either in MEL Books or tutorial about the procedure that is declared this way global proc string[] objectSelectMasks(string $item), though i understand its string type array , does that mean it returns string or something else :hmm:
global proc string[] objectSelectMasks(string $item)
// Returns the component selection masks that apply to this object
{
string $maskList[];
string $shape = $item;
int $i;

// Look at the shape child of this object
//
string $object[] = `listRelatives -path -s $item`;

int $gotVisible = 0;

for ($i = 0; $i < size($object); ++$i) {
if( (0 == getAttr($object[$i] + ".io")) &&
getAttr($object[$i] + ".v") ) {
$shape = $object[$i];
$gotVisible = 1;
break;
}
}

if( !$gotVisible ) {
for ($i = 0; $i < size($object); ++$i)
{
if (getAttr($object[$i] + ".io") == 0)
{
$shape = $object[$i];
break;
}
}
}


and so i am trying to take the value of what is return by the object, but my condition to validate what i want is if its not in any sub mode or if its not any joint , the do some function like doDelete;

RyanT
02-07-2009, 06:27 AM
Your post is kind of confusing. I think you are asking how to make a script execute when a certain action is taken by the user. I suggest looking up the scriptJob command. You can create a scriptJob to constantly check if the user is performing a certain action. You cant do it with any action, only the ones available to scriptJob. You can do things like have a script run before someone renders or after. You can have it run with a user selected a node.

As for your other question if you have a proc define a type then yes it returns that type. If it is a string[] then that is an array of strings. If it said int[] then that would be an array of ints and if it said string only it would return one string. MEL does not put strings into an array of characters like C++ if you have used C++ before.

Hope that helps.

DEVILSAN
02-07-2009, 08:41 AM
hmmm actually i am made a script before that keeps backup of selected object if deleted, but now i want if i delete a face or edge it should not run , so i want to keep a check if selection mode is not Sub selection i.e. if not edge , facet, vertex then do Delete ...

else do nothing..

the above code that i hav pasted is from the dagMenuProc.mel i found while searching how to get to know using mel for what selection mode i am currently in.

CGTalk Moderation
02-07-2009, 08:41 AM
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.