一半君的总结纸

听话只听一半君

#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 ‘listRelatives’ command to see if the transform has any associated shape nodes of its own:

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" );
}

Tuesday, March 27, 2001

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: