Parameter.AddScriptedOp

Introduced

v4.0

Description

Creates a new runtime scripted operator and connects its output to this object. If the scripting code is not specified then a default implementation will be used. For parameter connections a simple assignment of the current value will be created; for example, 'out.Value = 0.00'.

Specifying the scripting language is optional. If not specified then the current scripting language user preference will be used.

Tip: This is the Object Model version of the AddScriptedOp command, which also creates a runtime scripted operator. To create a Self-Installed Custom Operator, use the AddCustomOp command or Parameter.AddCustomOp method.

C# Syntax

CustomOperator Parameter.AddScriptedOp( String bszCode, Object vInputs, String bszName, String bszLanguage );

Scripting Syntax

Parameter.AddScriptedOp( [Code], Inputs, [Name], [Language] );

Parameters

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

Examples

JScript Example

/*
	This example demonstrates how to create a simple expression-like scripted operator
	to constrain the posx of an object to its posy value
*/
NewScene( null, false );
var obj = Application.ActiveSceneRoot.AddNull();
obj.posx.AddScriptedOp( myexpr_Update.toString(), obj.posy, "myexpr", "JScript" );
function myexpr_Update( ctx, out, inposy )
{
	out.Value = inposy;
}

See Also

AddScriptedOp ConvertScriptedOp CustomOperator Parameter.Source Parameter.AddScriptedOpFromFile ProjectItem.AddScriptedOp ProjectItem.AddScriptedOpFromFile