Creates a new scripted operator and connects its output to this object. If the scripting file is not specified then a default implementation is used. 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 used.

C# Syntax

CustomOperator ProjectItem.AddScriptedOpFromFile( String bszFileName, Object vInputs, String bszName, String bszLanguage, siConstructionMode in_constructionmode );

Scripting Syntax

oReturn = ProjectItem.AddScriptedOpFromFile( [FileName], Inputs, [Name], [Language], [ConstructionMode] );

Return Value



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

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


JScript Example

	This example creates a simple expression-like scripted operator
	which constrains the rotation of one object to another
NewScene( null, false );
var obj1 = GetPrim( "null" );
var obj2 = GetPrim( "null" );
// Create script file on disk
var filename = XSIUtils.BuildPath( 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() );
// Apply operator
var col = XSIFactory.CreateActiveXObject( "XSI.Collection" );
col.Add( obj1.Kinematics.Global );
col.Add( obj2.Kinematics.Global );
obj1.Kinematics.Global.AddScriptedOpFromFile( filename, col, "myexpr", "JScript" );
function myexpr_Update( ctx, out, inglobal1, inglobal2 )
	var transfo = inglobal1.Value.Transform;
	var rot = XSIMath.CreateRotation();
	transfo.SetRotation( rot );
	out.Value.Transform = transfo;

See Also

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