MEL How-To #20

Back · Previous · Next Maya

How can I determine the world space coordinates of NURBS surface edit points?

Determine the U and V values for the edit point. My attempts to do this yielded the following:

Create a surfaceInfo node and connect it to the NURBS surface, then query its '.knotsU' and '.knotsV' attributes:

createNode surfaceInfo;
// Result: surfaceInfo1 //

connectAttr -f nurbsPlane1.worldSpace surfaceInfo1.inputSurface;

getAttr surfaceInfo1.knotsU;
// Result: 0 0 0 0.333333 0.6666667 1 1 1 //

getAttr surfaceInfo1.knotsV;
// Result: 0 0 0 0.25 0.5 0.75 1 1 1 //

This would be from a nurbsPlane with 3 spans in U and 4 spans in V. Ignore the first two 0's and the last two 1's (this may or may not be the case for all surfaces). So, for the edit point at the intersection of the second U span and the second V span would be:

U = 0.33333 V = 0.25

Create a pointOnSurface node at these coordinates:

string $posNode = `pointOnSurface -ch on -u 0.3333 -v .25 nurbsSurface1`;

Query the position of the pointOnSurface node:

float $posCoord = `getAttr ( $posNode + ".position" )`;