Port

Object Hierarchy | Related C++ Class: Port

Inheritance

SIObject

Port

Introduced

v1.5

Description

A port is an InputPort or OutputPort connection to another object. Actually, a port is more like a connection point on an operator, which may or may not be actually connected to something (some operator ports are optional).

Use SIObject.Name to get the name of this port.

Methods

IsClassOf operator IsEqualTo operator    
       

Properties

Application BranchGroup operator Categories Flags operator
FullName operator GroupIndex operator GroupInstance operator GroupName operator
Help Index operator IsConnected Name operator
NestedObjects Origin OriginPath Parent
PortType operator Target operator Target2 operator TargetPath operator
Type operator      
       

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 );
var arc = Application.ActiveSceneRoot.AddGeometry( "Arc", "NurbsCurve" );
// Duplicate arc 4 times and translate in y
var args = new Array(19);
args[0] = arc;                                  // source object
args[1] = 4;                                            // number of copies
args[9] = siApplyRepeatXForm;                   // Xform
args[18] = 1;                                   // Ty
var objs = Application.ExecuteScriptCommand( "Duplicate", args );
// Create array containing arc and duplicates
var aobjs = new Array( 5 )
aobjs[0] = arc;
for ( var i = 0; i < objs.count; i++ ) aobjs[i+1] = objs(i);
// Apply loft operator
var op = ApplyOp( "Loft", aobjs )(0);
// Traverse port group, instances and ports and 
// log port connections
// For each port group ...
for ( var idxGroup = 0; idxGroup < op.GetNumPortGroups(); idxGroup++ )
{
        // For each instance in a port group ...
        for ( var idxInstance = 0; idxInstance < op.GetNumInstancesInGroup( idxGroup ); idxInstance++ )
        {
                // For each port in a  port group instance ...
                for ( var idxPort = 0; idxPort < op.GetNumPortsInGroup( idxGroup ); idxPort++ )
                {
                        // Get a specific port
                        var port = op.PortAt( idxPort, idxGroup, idxInstance );
                        // If the port is an input port ...
                        if ( port.PortType == siPortInput )
                                porttypestr = "input"
                        else if ( port.PortType == siPortOutput )
                                porttypestr = "output"
                        else
                                porttypestr = "error"
                        var target = port.Target2;
                        // ... and the connected type is an object connection
                        if ( typeof(target) == "object" )
                        {
                                Application.LogMessage( op.Name + " group:" + port.GroupIndex + " " + " instance:" 
                                                        + port.GroupInstance + " " + porttypestr + "port:" + port.Index 
                                                        + ":" + target.FullName );
                        }
                } 
        }
}
//INFO : "Loft group:0  instance:0 inputport:0:arc.crvlist"
//INFO : "Loft group:0  instance:0 inputport:1:arc.kine.global"
//INFO : "Loft group:0  instance:1 inputport:0:arc1.crvlist"
//INFO : "Loft group:0  instance:1 inputport:1:arc1.kine.global"
//INFO : "Loft group:0  instance:2 inputport:0:arc2.crvlist"
//INFO : "Loft group:0  instance:2 inputport:1:arc2.kine.global"
//INFO : "Loft group:0  instance:3 inputport:0:arc3.crvlist"
//INFO : "Loft group:0  instance:3 inputport:1:arc3.kine.global"
//INFO : "Loft group:0  instance:4 inputport:0:arc4.crvlist"
//INFO : "Loft group:0  instance:4 inputport:1:arc4.kine.global"
//INFO : "Loft group:1  instance:0 inputport:0:surfmsh.kine.global"
//INFO : "Loft group:1  instance:0 outputport:1:surfmsh.surfmsh"