v4.0
Creates a new scripted operator and connects its output to this object. If the scripting code is not specified then a default implementation is used. The scripting language is optional, if not specified then current scripting language user preference will used.
oReturn = ProjectItem.AddScriptedOp( [Code], Inputs, [Name], [Language], [ConstructionMode] ); |
Parameter | Type | Description |
---|---|---|
Code | String | The script code containing the implementation of the scripted operator. |
Inputs | List | List of objects or parameters to be connected to input ports. |
Name | String | The name of the new operator
Default Value: ScriptedOp |
Language | String | The script language of the new scripted operator
Default Value: Preference value from application.preferences.scripting.language |
ConstructionMode | siConstructionMode | The location in the construction stack where the operator
should be created. This only applies to output connections made to
Geometry objects; this mode will be
ignored for all other types of connections.
Default Value: siConstructionModeDefault |
/* This example creates a simple expression-like runtime scripted operator which constrains the rotation of one object to another */ NewScene( null, false ); var obj1 = GetPrim( "null" ); var obj2 = GetPrim( "null" ); var col = XSIFactory.CreateActiveXObject( "XSI.Collection" ); col.Add( obj1.Kinematics.Global ); col.Add( obj2.Kinematics.Global ); obj1.Kinematics.Global.AddScriptedOp( myexpr_Update.toString(), col, "myexpr", "JScript" ); function myexpr_Update( ctx, out, inglobal1, inglobal2 ) { var transfo = inglobal1.Value.Transform; var rot = XSIMath.CreateRotation(); inglobal2.Value.Transform.GetRotation(rot); transfo.SetRotation( rot ); out.Value.Transform = transfo; } |