一半君的总结纸

听话只听一半君

#58 How do I determine how many CVs are in a NURBS Curve or Surface?

To determine how many CVs are in a curve:

  string $curve = "curveShape1";

  int $numSpans = `getAttr ( $curve + ".spans" )`;
  int $degree   = `getAttr ( $curve + ".degree" )`;
  int $form     = `getAttr ( $curve + ".form" )`;

  int $numCVs   = $numSpans + $degree;

  // Adjust for periodic curve:
  if ( $form == 2 ) $numCVs -= $degree;

To select all CVs in this curve:

  select ( $curve + ".cv[0:" + ($numCVs-1) + "]" );

  // or simply...
  select ( $curve + ".cv[*]" );

To determine how many CVs are in a surface:

  string $surface = "nurbsSphereShape1";

  int $numSpansU = `getAttr ( $surface + ".spansU" )`;
  int $degreeU   = `getAttr ( $surface + ".degreeU" )`;

  int $numSpansV = `getAttr ( $surface + ".spansV" )`;
  int $degreeV   = `getAttr ( $surface + ".degreeV" )`;

  int $formU     = `getAttr ( $surface + ".formU" )`;
  int $formV     = `getAttr ( $surface + ".formV" )`;

  int $numCVsU   = $numSpansU + $degreeU;
  // Adjust for periodic hull:
  if ( $formU == 2 ) $numCVsU -= $degreeU;

  int $numCVsV   = $numSpansV + $degreeV;
  // Adjust for periodic hull:
  if ( $formV == 2 ) $numCVsV -= $degreeV;

  // Total CVs is U count times V count.
  int $numCVs = $numCVsU * $numCVsV;

To select all CVs in this surface:

  select ( $surface + ".cv[0:" + ($numCVsU-1) + "][0:"
                               + ($numCVsV-1) + "]" );

  // or simply...
  select ( $surface + ".cv[*][*]" );

Related How-To’s

29 Jan 2005

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 博主赞过: