v4.0
Adds an InputPort and an OutputPort to the custom operator. This is
equivalent to calling CustomOperator.AddOutputPort
followed by CustomOperator.AddInputPort.
Note: Having both an output and input connection is very important
for correct functioning of deformation operators and other
operators that modify the existing state of an object. Otherwise
the operator will not co-exist properly with other operators. That
is, although there will be two ports representing the same object,
they may point to different copies of that object, so it is
important that the operator reads the object state exclusively via
the input and changes the object through the output.
PortCollection CustomOperator.AddIOPort( Object in_PortTarget, String in_PortName, Int32 in_portgroup, Int32 in_InsertAt, Int32 in_flags ); |
oReturn = CustomOperator.AddIOPort( PortTarget, [PortName], [PortGroup], [InsertAt], [Flags] ); |
The newly created input and output ports in a PortCollection object.
Parameter | Type | Description |
---|---|---|
PortTarget | Variant | Object or expression representing the object to connect to the port. Softimage will remember the full name of the object, but this can be overridden at connection time to connect to a different object (see Operator.Connect and Operator.ConnectToGroup). |
PortName | String | The name of the ports. If a name is not specified then the
names of the input and output ports are created automatically. The
input port has "In" prefixed to the name plus the Parameter.ScriptName of the object
connected to the port. The output port is the same but with the
prefix "Out".
Default Value: "" (empty string) |
PortGroup | Long | Index of the port group.
Default Value: -1 (add to end of port groups) |
InsertAt | Long | Index of the port at a specific index.
Default Value: -1 (add to end of ports within port group) |
Flags | Long | Mask of port group flags described by siPortFlags.
Default Value: 0 |
/* This example illustrates how to use the AddIOPort method to define an input/output port. */ NewScene( null, false ); var obj = CreatePrim( "Cube", "MeshSurface"); var sop = XSIFactory.CreateScriptedOp( "MyOperator", MyOperator_Update.toString(), "JScript" ) sop.AddIOPort( obj.ActivePrimitive ); sop.Connect(); // The operator's update function function MyOperator_Update( ctx, out, in1 ) { Application.LogMessage( "MyOperator_Update: " + out.Value ); var aPos = in1.Value.Geometry.Points.PositionArray.toArray(); out.Value.Geometry.Points.PositionArray = aPos; } |