MEL How-To #60 | ||
| ||
How do I determine if a transform is a Group node?A "group" node is simply an empty transform, often with other transforms (and their associated child shapes) as children. So the first thing to confirm is that the node is in fact a transform node: if ( `nodeType $possibleGroupNode` != "transform" ) { print ( $possibleGroupNode + " can't possibly be a group node.\n" ); } Next I would suggest the use of the ‘ string $possibleGroupNode = "group1"; if ( size( `listRelatives -shapes $possibleGroupNode` ) == 0 ) { print ( "Transform without Shape: Possibly a group node.\n" ); }You could enhance the query to see if the node has only other transforms as children:
int $onlyTransforms = true;
string $groupChildren[] = `listRelatives -children $possibleGroupNode`;
if ( size( $groupChildren ) == 0 )
{
print ( "Empty transform.\n" );
}
else
{
// iterate children and see if they're all transforms themselves...
for ( $child in $groupChildren )
{
if ( `nodeType $child` != "transform" )
{
$onlyTransforms = false;
break;
}
}
}
if ( $onlyTransforms )
{
print ( "Transform has only other transforms as children.\n" );
print ( $possibleGroupNode + " may be considered a Group node.\n" );
}
else
{
print ( $possibleGroupNode + " is not a simple Group node.\n" );
}
| ||
Copyright ©2005 by Bryan Ewert, maya@ewertb.com Maya is a Registered Trademark of Alias |