/*
This example illustrates how to get the number of instances within operator's
port groups.
*/
NewScene( null, false );
var arc = CreatePrim( "Arc", "NurbsCurve" );
// Duplicate arc 3 times and translate in z by 45
var args = new Array(19);
args[0] = arc; // source object
args[1] = 3; // number of copies
args[9] = siApplyRepeatXForm; // Xform
args[15] = 90; // Rz
var arcs = Application.ExecuteScriptCommand( "Duplicate", args );
// Create mesh from curves
ApplyOp( "CrvNet", arc +","+arcs(1)+";"+arcs(0)+","+arcs(2) );
// Get mesh from selection
var mesh = Selection(0);
// Get boolean operator from cube's construction history
var e = new Enumerator( mesh.ActivePrimitive.ConstructionHistory );
var op;
for ( ; !e.atEnd(); e.moveNext() )
if ( e.item().Type == "curvenet" )
{
op = e.item();
break;
}
// Print the number of ports in each group
Application.LogMessage( op.Name + ": num port groups = " + op.GetNumPortGroups() );
for ( var i=0; i<op.GetNumPortGroups(); i++ )
Application.LogMessage( op.Name + ": num instances in group " + i + " = " + op.GetNumInstancesInGroup(i) );
//INFO : "Curve Net: num port groups = 3"
//INFO : "Curve Net: num instances in group 0 = 2"
//INFO : "Curve Net: num instances in group 1 = 2"
//INFO : "Curve Net: num instances in group 2 = 1"
|