Null Values

how do you test if a variable has a null value? I have a variable assignment:
$isShape = ls -sl -s;
to test whether a selection is a shape node or not (is there an easier way to do this?). If the selection isn't a shape node this variable doesn't seem to have a type, and maya complains when I do anything with it. so how do you test to see if it has a null value? There doesn't seem to be a null reserved word or anything according to the docs...

PS does anyone know of an easier way to test if an selection is a shape node or not? if not I want to select its parent.

If I am understanding what you want the test can be done with an if...

if ($isShape[0] == "")

Empty quotes are a null. You should declare $isShape as a string before your assignment if this command might return a null.

--JeffD

thats exactly what I thought too. but it doesn't seem to work that way. just as an example, select a shape node (i just created a sphere, and pressed down), and then run this code:

string $isShape = ls -sl -s;
string $temp = ($isShape == "") ? "yes it is" : "no it isn't";
print $temp;

it gives me this error:
// Error: line 1: Cannot convert data of type string[] to type string. //

and trying to change the $isShape == "" to: $isShape[0] == "" doesn't work because the array is an empty array. doing a size on that array doesn't seem to work either.

is there anyway I can determine if I have a shape node or a transform node selected?
Thanks.

use size

string $isShape[] = ls -sl -s;

if ( size($isShape) )
{
//got here so something in shape
}
else
{
//shape array is empty
}

g-

ha, HA... indeed a smart idea. thanks heaps for that. Much appreciated.

The problem with your version is that ls -sl -s is going to return an array value. You cannot compare a whole array (even an empty one). When you test $isShape it needs to be...

string $temp = ($isShape[0] == "")

This one gets me all the time

--JeffD