// JScript example : shows how to retrieve the output arguments returned by NurbsSurface.GetTrim2
// Create a sphere with some trims first
CreatePrim("Sphere", "NurbsSurface", null, null);
CreatePrim("Square", "NurbsCurve", null, null);
Scale(null, -0.325581395348837, 1, 1, siRelative, siLocal, siObj, siXYZ, null, null, null, null, null, null, null, 0);
Scale(null, 1, 0.732558139534884, 1, siRelative, siLocal, siObj, siXYZ, null, null, null, null, null, null, null, 0);
SelectObj("sphere", null, true);
ApplyTopoOp("TrimByProjection", "sphere;square", 3, siPersistentOperation, null);
// get the trimmed surface
var surfs = Application.Selection(0).ActivePrimitive.Geometry.Surfaces;
// get the first trim parameters and convert VB array to JScript array
var vbArgs = new VBArray(surfs(0).GetTrim2( 0, siSINurbs ));
var args = vbArgs.toArray();
// get the bondary flag of curves
LogMessage("trim is boundary?: " + args[0] );
// get the projection type
LogMessage("projection type: " + args[1] );
// get the number of curves
LogMessage("number of curves: " + args[2] );
// get the number of control points per curve
var vbArg4 = new VBArray(args[4]);
var ncpoints = vbArg4.toArray();
for (i = 0; i < args[2]; i++)
{
LogMessage("number of control points for curve " + i + ": " + ncpoints[i] );
}
// get the control points
var vbArg3 = new VBArray(args[3]);
var cpts = vbArg3.toArray();
for ( i=0; i<ncpoints.length; i++ )
{
for ( j=0, k=0; k<ncpoints[i]; k++, j+=4 )
{
LogMessage("crv" + i + "[" + k + "]: " + cpts[j] + ", " + cpts[j+1] + ", " + cpts[j+2] + ", " + cpts[j+3] );
}
}
// get the number knots per curve
var vbArg6 = new VBArray(args[6]);
var nknots = vbArg6.toArray();
for (i = 0; i < nknots.length; i++)
{
LogMessage("number of knots for curve " + i + ": " + nknots[i] );
}
// get the knots
var vbArg5 = new VBArray(args[5]);
var knots = vbArg5.toArray();
for ( j=0; j<nknots.length; j++)
{
for (i = 0; i < nknots[j]; i++)
{
LogMessage("crv" + j + ": " + "knots" + i + ": " + knots[i] );
}
}
// get nurbs curves closeness state
var vbArg7 = new VBArray(args[7]);
var closes = vbArg7.toArray();
for (i = 0; i < closes.length; i++)
{
LogMessage("curve" + i + " closeness: " + closes[i] );
}
// get nurbs degree
var vbArg8 = new VBArray(args[8]);
var degrees = vbArg8.toArray();
for (i = 0; i < degrees.length; i++)
{
LogMessage("curve" + i + " degree: " + degrees[i] );
}
// get nurbs parameterization factor
var vbArg9 = new VBArray(args[9]);
var params = vbArg9.toArray();
for (i = 0; i < params.length; i++)
{
LogMessage("curve" + i + " parameterization: " + params[i] );
}
|