Example...
// Looking For This Object's Shape Node
string $object = "myObject" ;
string $shapeArr[] = `listRelatives -shape $object` ;
string $shapeNode = $shapeArr[0] ;
// The above returns an array, which is annoying. To me at least...
I'm aware you can use $shapeArr[0] as your shape node without redeclaring it into the second variable, but I've always felt it was sloppy to do it that way.
Here's a simple MEL procedure that makes it easier.
// **********************************************************
// Returns An Index From A String Array
global proc string jgArrToStr (string $array[], int $index) {
// Get Index From Array
string $obj = $array[$index] ;
// Return
return $obj ;
}
// Now you can do...
string $object = "myObject" ;
string $shape = jgArrToStr(`listRelatives -shape $object`, 0) ;
This will only work if you know the index you're looking for in the array, but a lot of times MEL returns string arrays when it doesn't need to and you know what it will be.