一半君的总结纸

听话只听一半君

#03 How can a get a list of all vertex or edge components that are associated with a polymesh face? (or vice versa)

There’s a nice little hidden (well, non-obvious anyway) MEL command that came to light with Quang Tran’s edgePath/facePath tools:

polyListComponentConversion

It returns a converted selection list, so all you need to do is assign the results of this command to a string array:

// Vertices associated with face
string $vtx[] = `polyListComponentConversion -toVertexFace pCube1.f[5]`;
// Result: pCube1.vtx[0] pCube1.vtx[2] pCube1.vtx[4] pCube1.vtx[6] //

// Edges associated with face
string $edge[] = `polyListComponentConversion -toEdge pCube1.f[1]`;
// Result: pCube1.e[1:2] pCube1.e[6:7] //

// Vertices associated with edge
string $vtx[] = `polyListComponentConversion -toVertex pCube1.e[1]`;
// Result: pCube1.vtx[2:3] //

// Faces associated with vertex
string $face[] = `polyListComponentConversion -toFace pCube1.vtx[1]`;
// Result: pCube1.f[0] pCube1.f[3:4] //

The “Old Way”

I originally used a “brute force” procedure and parsed the results of the ‘listAttr’ command to get the vertices associated with a face.

proc int[] facetVertices( string $facet )
{
   int $vertices[];
   int $numVertices = 0;

   string $attr[] = `listAttr $facet`;

   for ( $i = 0; $i < size( $attr ); $i+=4 )
   {
      $vertices[$numVertices++] = match( "[0-9]+", $attr[$i] );
   }

   return $vertices;
}

Related How-To’s

Thursday, January 18, 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 博主赞过: