一半君的总结纸

听话只听一半君

#60 如何知道一个 transform 是不是 Group node?

“group” node 其实就是一个空的transform, 通常他下面还有其他的 transforms (和他们自己的child shapes) 作为 children.

所以首先需要确认的是这个 node 是不是 transform node:

if ( `nodeType $possibleGroupNode` != "transform" )
{
  print ( $possibleGroupNode + " can't possibly be a group node.\n" );
}

然后我将建议使用 ‘listRelatives’ command 来看看这个 transform 有没有和她相关联的 shape nodes:

string $possibleGroupNode = "group1";

if ( size( `listRelatives -shapes $possibleGroupNode` ) == 0 )
{
  print ( "Transform without Shape: Possibly a group node.\n" );
}

你也可以把上面的改进一下, 看看这个node下面有没有其他的 transforms children:

int $onlyTransforms = true;

string $groupChildren[] = `listRelatives -children $possibleGroupNode`;

if ( size( $groupChildren ) == 0 )
{
  print ( "Empty transform.\n" );
}
else
{
  // 查询每个 children 看他们是不是都是 transforms ...
  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 博主赞过: