Operator
 
 
 

Operator

Object Hierarchy | Related C++ Class: Operator

Inheritance

SIObject

ProjectItem

Operator

Introduced

v1.5

Description

The Operator object represents an operator in the scene graph. Objects or Parameters are connected to the operator via InputPorts or OutputPorts, which may be organized into PortGroups. SDK users can create their own operators, which are represented in the Object Model as CustomOperators.

The responsibility of an operator is to change the output object (or objects) with the result of some algorithm. The only data the operator can read from the scene is via its input ports and parameters. For example, a typical operator might change the position of one object (the output) based on the position of several other objects (the inputs). The same object may act as both the input and the output of an operator, for example a typical deformation operator will read a geometry and output a modified version of the point positions of that same geometry. Selecting an operator in the "SDK Explorer" view is a good way to learn more about its ports and parameters.

To access individual ports from within the evaluation of a Self-Installed Custom Operator use the OperatorContext object. From outside the evaluation callback use the Operator.PortAt method.

Almost all Operators expose one or more Parameters which control the behavior of the operator. For example, the "subdivu" and "subdivv" parameters on a polygon mesh geometry operator control the number of polygons that a polygon mesh is generated with.

The most common way to create and connect a built-in operator is by calling the ApplyOp command. However, there are many specialized commands for creating operators, for example ApplyTopoOp, ApplyHairOp and ApplyGenOp. Operators are also often created indirectly, for example calling X3DObject.AddGeometry creates an operator that generates the geometry.

Methods

AddCustomOp AddICEAttribute AddScriptedOp AddScriptedOpFromFile
AnimatedParameters2 BelongsTo operator Connect ConnectToGroup
Copy Disconnect DisconnectGroup EvaluateAt
GetICEAttributeFromName GetInputValue GetNumInstancesInGroup operator GetNumPortGroups operator
GetNumPortsInGroup operator GetPort2 operator GetPort3 operator GetPortAt operator
IsA IsAnimated2 IsClassOf operator IsEqualTo operator
IsKindOf IsLocked operator IsSelected operator LockOwners
PortAt operator RemoveICEAttribute SetAsSelected operator SetCapabilityFlag operator
SetLock SupportsBranchGroup operator TaggedParameters UnSetLock

Properties

Application BranchFlag operator Capabilities operator Categories
EvaluationID Families operator FullName operator Help
HierarchicalEvaluationID ICEAttributes InputPorts operator IsConnected operator
LockLevel operator LockMasters operator LockType operator Model
Mute operator Name operator NestedObjects ObjectID
Origin OriginPath OutputPorts operator Owners
PPGLayout operator Parameters operator Parent Parent3DObject
Port operator PortGroups operator Selected 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 = 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 );
                        }
                } 
        }
}
// Expected results:
//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"

See Also

ConstructionHistory CustomOperator Envelope ApplyOp FreezeObj