/*
This example illustrates how to use the AddPortGroup method to define
an PortGroup. Use this method if you want to determine the number
of objects that can be connected to the group or restrict the
types of objects connecting to the group by using a filter.
*/
NewScene( null, false );
var obj = CreatePrim( "Cube", "MeshSurface");
var sop = XSIFactory.CreateScriptedOp( "MyOperator", MyOperator_Update.toString(), "JScript" )
var group = sop.AddPortGroup( "MainGroup", 1, 1, siPolyMeshFilter, "please pick a polygon mesh" );
sop.AddPortGroup( "MainGroup" );
sop.AddIOPort( obj.ActivePrimitive ); // this is an error - a second group will be created
// but the first group doesn't have any ports.
Application.LogMessage( "valid operator definition = " + sop.Validate() );
// 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;
} |