AddScriptedOpFromFile (Parameter)
Introduced
4.0
Description
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.
Scripting Syntax
Parameter.AddScriptedOpFromFile( [FileName], Inputs, [Name], [Language] )
C# Syntax
CustomOperator Parameter.AddScriptedOpFromFile( String bszFileName, Object vInputs, String bszName, String bszLanguage );Parameters
|
Parameter |
Type |
Description |
|
FileName |
The script filename containing the implementation of the scripted operator. |
|
|
Inputs |
List of objects or parameters to be connected to input ports. |
|
|
Name |
The name of the new operator Default Value: ScriptedOp |
|
|
Language |
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(); // 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; }
See Also
|
|
Autodesk Softimage v7.5