PortGroup

Object Hierarchy | Related C++ Class: PortGroup

Inheritance

    SIObject
       PortGroup

Introduced

4.0

Description

A portgroup is a group of Port objects on an Operator. The port group is a logical grouping of multiple port connections that are normally scoped by a X3DObject. A single portgroup can contain both InputPorts and OutputPorts.

Note: The PortGroup object should not be confused with the Group object.

You can determine the number of port groups defined by an operator using the Operator.GetNumPortGroups method and determine the number of ports in a PortGroup using the Operator.GetNumPortsInGroup method.

For built-in Operators the port groups contain all ports that will be connected to parts of the selected or picked object. For example, when the Twist operator is applied to a selected object, the operator has ports that read from the object's local KinematicState and Geometry and write to the result object's geometry.

However, for typical Self-Installed Custom Operators, all outputs and inputs can be in a single PortGroup because the individual targets for each port are specifically provided at the time of calls to CustomOperator.AddInputPort or AddCustomOp. In fact, the concept of PortGroup can be completely ignored for most custom operators. However any dynamic input inside an advanced operators should be in its own PortGroup to permit usage of Operator.ConnectToGroup.

Multiple objects can connect to the same port group, for example, the loft operator may read from many curves to generate the resulting mesh. Each of these input curves are connected to the same port group and each connection is called a port group instance. You can determine the number of objects connected to a port group by using Operator.GetNumInstancesInGroup or PortGroup.InstanceCount.

Use SIObject.Parent to get the Operator for this PortGroup and SIObject.Name to get the name of this port group.

From the port you can determine which port group a port belongs to using the Port.GroupName or Port.GroupIndex properties. You can determine which port group instance a port belongs to using the Port.GroupInstance property.

Methods

IsClassOf | IsEqualTo | IsOptional | SupportsBranchGroup

Properties

Application | Categories | Filter | Flags
FullName | Help | Index | InstanceCount
Max | Min | Name | NestedObjects
Origin | OriginPath | Parent | PickPrompt
Ports | Type |  |

Examples

JScript Example

    /*
       This example illustrates how to browse the port groups of an operator.
    */
    NewScene( null, false );
    CreatePrim( "Cylinder", "MeshSurface" );
    var op = ApplyOp( "Shear", "cylinder", 3, siPersistentOperation )(0);

    dump_portgroups(op);

    function dump_portgroups(op)
    {
       if ( ! op.BelongsTo("Operators") )
           return;

       var ePortGroups = new Enumerator( op.PortGroups );

       for ( ; ! ePortGroups.atEnd(); ePortGroups.moveNext() )
       {
           var portgroup = ePortGroups.item();
           var str = "";

           str += "group name: " + portgroup.Name;
           str += ", type: " + portgroup.Type;
           str += ", parent: " + portgroup.Parent;
           str += ", index: " + portgroup.Index;
           str += ", flags: " + portgroup.Flags;
           str += ", min: " + portgroup.Min;
           str += ", max: " + portgroup.Max;
           str += ", filter: " + portgroup.Filter;
           str += ", pickprompt: " + portgroup.PickPrompt;
           str += ", optional: " + portgroup.IsOptional();
           str += ", branchgroup: " + portgroup.SupportsBranchGroup();
           Application.LogMessage( str );

           var ePorts = new Enumerator( portgroup.Ports );

           for ( ; ! ePorts.atEnd(); ePorts.moveNext() )
           {
              var port = ePorts.item();
              dump_port(port);
           }
       }
    }

    function dump_port(port)
    {
       var str = "";

       str += "port name: " + port.Name;
       str += ", type: " + port.Type;
       str += ", porttype: " + port.PortType;
       str += ", connected: " + port.IsConnected;
       if ( port.IsConnected)
           str += ", target: " + port.Target2;
       str += ", parent: " + port.Parent;
       str += ", index: " + port.Index;
       str += ", flags: " + port.Flags;
       if ( port.Type == "InputPort" )
           str += ", optional: " + port.Optional;
       if ( port.type == "OutputPort" )
           str += ", created: " + port.Created;
       str += ", branchgroup: " + port.BranchGroup;
       str += ", groupname: " + port.GroupName;
       str += ", groupindex: " + port.GroupIndex;
       str += ", groupinstance: " + port.GroupInstance;

       Application.LogMessage( str );
    }

    // Expected result:
    //INFO : group name: Group_0, type: PortGroup, parent: cylinder.polymsh.shearop, index: 0, flags: 513, min: 1, max: 1, filter: DeformableComponent, pickprompt: Deformation Value, optional: false, branchgroup: true
    //INFO : port name: Port_0, type: InputPort, porttype: 0, connected: false, parent: cylinder.polymsh.shearop, index: 0, flags: 1026, optional: false, branchgroup: true, groupname: Group_0, groupindex: 0, groupinstance: -1
    //INFO : port name: Port_2, type: InputPort, porttype: 0, connected: false, parent: cylinder.polymsh.shearop, index: 1, flags: 1088, optional: false, branchgroup: true, groupname: Group_0, groupindex: 0, groupinstance: -1
    //INFO : port name: Port_3, type: InputPort, porttype: 0, connected: false, parent: cylinder.polymsh.shearop, index: 2, flags: 64, optional: false, branchgroup: false, groupname: Group_0, groupindex: 0, groupinstance: -1
    //INFO : port name: Port_4, type: InputPort, porttype: 0, connected: false, parent: cylinder.polymsh.shearop, index: 3, flags: 24, optional: true, branchgroup: false, groupname: Group_0, groupindex: 0, groupinstance: -1
    //INFO : port name: Port_5, type: InputPort, porttype: 0, connected: false, parent: cylinder.polymsh.shearop, index: 4, flags: 24, optional: true, branchgroup: false, groupname: Group_0, groupindex: 0, groupinstance: -1
    //INFO : port name: Port_1, type: OutputPort, porttype: 1, connected: false, parent: cylinder.polymsh.shearop, index: 5, flags: 525313, created: false, branchgroup: true, groupname: Group_0, groupindex: 0, groupinstance: -1
    //INFO : group name: Group_1, type: PortGroup, parent: cylinder.polymsh.shearop, index: 1, flags: 128, min: 0, max: 1, filter: , pickprompt: , optional: true, branchgroup: false
    //INFO : port name: Port_0, type: InputPort, porttype: 0, connected: false, parent: cylinder.polymsh.shearop, index: 0, flags: 24, optional: true, branchgroup: false, groupname: Group_1, groupindex: 1, groupinstance: -1

See Also

Operator.GetNumInstancesInGroup

Autodesk Softimage v7.5