MEL How-To #08 | ||
| ||
How do I find the Shape node of a Transform? Or the Transform of a Shape node?To get the list of Shape nodes from a Transform:
proc string[] getShapes( string $xform )
{
string $shapes[];
$shapes[0] = $xform;
if ( "transform" == `nodeType $xform` )
// If given node is not a transform, assume it is a shape
// and pass it through
{
$shapes = `listRelatives -fullPath -shapes $xform`;
}
return $shapes;
}
Note that this returns a string array, as it is possible for a single transform to be the parent of multiple shape nodes. To get the Transform from a Shape node:
proc string getTransform( string $shape )
{
string $transform = "";
if ( "transform" != `nodeType $shape` )
// If given node is already a transform, just pass on through
{
string $parents[] = `listRelatives -fullPath -parent $shape`;
$transform = $parents[0];
}
return $transform;
}
Related How-To's11 May 2003 | ||
| Copyright ©2005 by Bryan Ewert, maya@ewertb.com Maya is a Registered Trademark of Alias |