v4.0
Creates a new scripted operator and connects its output to this
object. If the scripting file 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 language associated with the file extension will be used.
If this cannot be determined then the current scripting language
user preference will be used.
Parameter.AddScriptedOpFromFile( [FileName], Inputs, [Name], [Language] ); |
Parameter | Type | Description |
---|---|---|
FileName | String | The script filename 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 |
/* 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(); // Create script file on disk var filename = Application.InstallationPath( siUserPath ) + "\\Data\\Scripts\\myexpr_sop.js"; var fso = new ActiveXObject( "Scripting.FileSystemObject" ); var f = fso.CreateTextFile( filename, true ); f.Write( myexpr_Update.toString() ); f.Close(); // Apply scripted operator obj.posx.AddScriptedOpFromFile( filename, obj.posy, "myexpr", "JScript" ); // Expression Update function function myexpr_Update( ctx, out, inposy ) { out.Value = inposy; } |