MEL How-To #04

Back · Previous · Next Maya

Given a polymesh edge component, how can I get a list of its associated vertices?

proc int[] edgeVertices( string $edge )
  int $vertices[2];

  string $vlist[] = `listAttr $edge`;

  $vertices[0] = match( "[0-9]+", $vlist[0] );
  $vertices[1] = match( "[0-9]+", $vlist[4] );

  return $vertices;

However, Maya always returns the vertices in numeric order and not in what I call "construction order." For example, if you activate the PolyAppendTool and pick an edge, you'll see an arrow that defines the "vector" for that edge. The order of the vertices returned does not necessarily match the orientation of this vector.

Per the documentation on the 'mesh' DG Node you're supposed to be able to query this using:

getAttr polymesh.e[0];

or more directly, possibly something like:

getAttr polymesh.e[0].edg1;
getAttr polymesh.e[0].edg2;

However, that appears to be broken (at least in MEL) right now. Maya Tech Support is currently investigating this.