Nurbs Curves within Maya are geometry objects that are parented
underneath a transform node.
Creating a NURBS Curve
To create a NURBS curve in mel, simply using the curve
command using the -p flag to specify
the point values.
// Use the curve command to create a curvecurve -p 0 0 0 -p 5 0 0 -p 5 0 5 -p 0 0 5;
Finding All Nurbs Curves in a Scene
fgetword simply reads the next word in the file and returns
it as a text string.
// get a list of all curves in the scene
$curves = `ls -type "curve"`;
// loop through each curvefor( $curve in $curves )
{
// print the name of the curveprint( $curve + "\n" );
}
Accessing local Space Control Points
Nurbs Curve information should be accessed using a curve info
node. Once attached to the curve this should provide you will
all the information you need for the curve.
Knot vectors in Maya are slightly different to those normally
described in 3D Geometry textbooks.
procgetCurveKnots( string $curve )
{
// attach a curve info node to the curvestring $infoNode = `createNode curveInfo`;
connectAttr ($curve +".worldSpace") ($infoNode+".inputCurve");
// Curve Typeint $form = eval("getAttr " + $curve + ".form");
// get the knot valuesfloat $Knots[] = `getAttr ($infoNode+".knots")`;
// output knotsprint( "numKnots= " + (`size($Knots)`+2) + "\n");
// insert an additional knot at the front....if($form == 2)
{
print ($Knots[0]-1);
}
else
{
print $Knots[0];
}
for($i=0;$i< size($Knots);$i++)
{
print (" "+$Knots[$i]);
}
// insert an additional knot at the end....if($form == 2)
{
print (($Knots[size($Knots)-1]+1) + "\n");
}
else
{
print ($Knots[size($Knots)-1] + "\n");
}
// delete the curve info nodedelete $infoNode;
}
Accessing Curve Information
Nurbs Curve information should be accessed using a curve info
node. Once attached to the curve this should provide you will
all the information you need for the curve.
procgetCurveInfo( string $curve )
{
// attach a curve info node to the curvestring $infoNode = `createNode curveInfo`;
connectAttr ($curve +".worldSpace") ($infoNode+".inputCurve");
// Curve Type
int$form = eval("getAttr " + $curve + ".form");
// Curve Degreeint $degree = eval("getAttr " + $curve + ".degree");
// Curve Spansint $spans = eval("getAttr "+$curve+".spans");
// delete the curve info nodedelete $infoNode;
}