`ls -sl`will return names of all selected objects. In your example you are storing the names in a string array. To get a value of an attribute of some selected object you use the getAttr command. An example:
Let's say we want to find out if a poly object (a mesh) called myObjectShape is in the selection and if it's displayVertices attribute is set.
Code:
string $sSel[] = `ls -sl -dag -typ mesh`; // Notice the use of -dag and -typ switches.
// Normally you're only selecting transform nodes in the Maya view ports.
// The -dag is used to list all the shape nodes (among other things) as well.
// We're only interested in mesh objects so with the -typ mesh we'll limit the
// ls command to list meshes only in the selection
int $iSize = size($sSel), $i;
if($iSize > 0)
{
for($i = 0; $i < $iSize; $i++)
{
if($sSel[$i] == "myObjectShape")
{
// By looking in to the DG Node reference we know that the .dv attribute is a boolean.
// However we define booleans as integers because there is no bool type in mel.
int $bDv = `getAttr ($sSel[$i] + ".dv")`; // Now the $bDv variable contains the value of myObjectShape.dv
// Let's find out if it's set
if($bDv)
{
print("myObjectShape.dv is on\n");
// <Do other stuff what needs to be done if the attribute is set>
}
else
{
print("myObjectShape.dv is off\n");
// <Do other stuff what needs to be done if the attribute is not set>
}
}
else
warning("myObjectShape could not be found in the selection!\n");
}
}
else
{
warning("Nothing selected...\n");
}
Not sure if this is a good example. Lemme know if there's something that needs to be clarified more elaborately.
Last edited by kbrown; 04-06-2003 at 01:51 PM.