Operator.GetNumPortGroups operator

Introduced

v3.0

Description

Returns the number of PortGroups (or -1 if there is a failure). Operators that do not define port groups, namely ones created in the scripted operator editor or expressions, report that they have one port group. This is not strictly correct but allows the user to write generic code for accessing the ports (see the example for the Operator object.

The PortGroupCollection.Count property (which can be accessed from Operator.PortGroups) returns 0.

C# Syntax

Int32 Operator.GetNumPortGroups();

Scripting Syntax

oLong = Operator.GetNumPortGroups();

Return Value

Long

Examples

JScript Example

/*
	This example illustrates how to generate a mesh by using the loft operator and
	a number of input curves. The code also illustrates how to traverse the operator's
	port group, port group instances and ports and logs the name of the port, its type
	and the full path name of the object connected to the port.
*/
NewScene( null, false );
CreatePrim( "Grid", "NurbsSurface" );
// Bend grid	
ApplyOp( "Bend", grid );
// Get grid from selection
var grid = selection(0);
// Get bend operator from the grid's construction history
var e = new Enumerator( grid.ActivePrimitive.ConstructionHistory );
var op;
for ( ; ! e.atEnd(); e.moveNext() )
if ( e.item().type == "bendop" )
{
op = e.item();
break;
}
// Print the number of port groups defined by the bend operator
Application.LogMessage( op.Name + ": num port groups = " + op.GetNumPortGroups() );
// Expected result:
// INFO : "Bend Op: num port groups = 1"