## Operator.GetNumInstancesInGroup

### Introduced

v3.0

### Description

Returns the number of instances in a PortGroup (or -1 if there is a failure).

### C# Syntax

    Int32 Operator.GetNumInstancesInGroup( Int32 in_lPortGroupIndex );

### Scripting Syntax

    oLong = Operator.GetNumInstancesInGroup( PortGroupIndex );

### Return Value

Long

### Parameters

Parameter | Type | Description
--- | --- | ---
PortGroupIndex | Long | Port.GroupIndex

### Examples

#### JScript Example

    /*

    	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"