// This example shows how to retrieve the output arguments returned by NurbsCurveList.Get2
var oRoot = Application.ActiveProject.ActiveScene.Root;
var oGrid = oRoot.AddGeometry( "Grid", "NurbsSurface" );
oGrid.subdivu = 1;
oGrid.subdivv = 1;
Duplicate( "grid", null, 2, 1, 1, 0, 0, 1, 0, 1 );
AddToSelection( "grid,grid1", null, 1 );
SIAssembleNurbsMesh( null, 0.150, 0, 0, 1 );
SelectObj( "surfmsh" );
// convert VB array to JScript array
var vbArgs = new VBArray(Selection(0).ActivePrimitive.Geometry.Get2( siSINurbs ));
// get the number of surfaces
numSurfs = vbArgs.getItem(0);
LogMessage("number of surfaces: " + numSurfs);
// get the number of control points in U per surface
var uncpts = vbArgs.getItem(2);
uSize = uncpts.ubound(1)-uncpts.lbound(1)+1;
for (i = 0; i < uSize; i++)
{
LogMessage("number of control points in U for surface " + i + ": " + uncpts.getItem(i) );
}
// get the number of control points in V per surface
var vncpts = vbArgs.getItem(3)
vSize = vncpts.ubound(1)-vncpts.lbound(1)+1;
for (i = 0; i < vSize; i++)
{
LogMessage("number of control points in V for surface " + i + ": " + vncpts.getItem(i) );
}
// get the control point array
var cpts = vbArgs.getItem(1);
// dump all control points
for ( k=0, offset=0; k<numSurfs; offset += uncpts.getItem(k), k++ )
{
for ( i=0; i<vncpts.getItem(k); i++ ) // V
{
for ( j=0; j<uncpts.getItem(k); j++ ) // U
{
idx = j+offset;
LogMessage("surf" + k + ": cpts[0]" + "[" + i + "]" + "[" + idx + "]: " + cpts.getItem(0,i,idx));
LogMessage("surf" + k + ": cpts[1]" + "[" + i + "]" + "[" + idx + "]: " + cpts.getItem(1,i,idx));
LogMessage("surf" + k + ": cpts[2]" + "[" + i + "]" + "[" + idx + "]: " + cpts.getItem(2,i,idx));
LogMessage("surf" + k + ": cpts[3]" + "[" + i + "]" + "[" + idx + "]: " + cpts.getItem(3,i,idx));
}
}
} |