ProjectItem.AddScriptedOpFromFile

導入

v4.0

詳細

新しいスクリプトオペレータを作成し、その出力をこのオブジェクトに接続します。スクリプトファイルが指定されていない場合には、デフォルトの実装が使用されます。スクリプト言語は省略できます。指定しない場合には、ファイル拡張子に関連付けられている言語が使用されます。これで言語が特定できない場合は、現在のスクリプト言語のユーザプリファレンスが使用されます。

スクリプト 構文

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

戻り値

CustomOperator

パラメータ

パラメータ タイプ 詳細
FileName String スクリプト オペレータの実装を含むスクリプトのファイル名
入力 List 入力ポートに接続するオブジェクトまたはパラメータのリスト
Name String 新しいオペレータの名前

デフォルト値: ScriptedOp

Language String 新しいスクリプトオペレータのスクリプト言語

デフォルト値:application.preferences.scripting.languageから取得した設定値

ConstructionMode siConstructionMode オペレータが作成されるコンストラクションスタックの位置。これは、Geometryオブジェクトに対して作成された出力接続にのみ適用されます。その他のすべての接続タイプではモードは無視されます。

デフォルト値:siConstructionModeDefault

JScript の例

/*
        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() );
f.Close();
// 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();
        inglobal2.Value.Transform.GetRotation(rot);
        transfo.SetRotation( rot );
        out.Value.Transform = transfo;
}

関連項目

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