このコールバックはコマンドを起動するたびに発生します。
このコールバックはコマンドを実装するために使用します。 ここで引数を処理し、いくつかの処理を実行してから、結果を返します(結果がある場合)。 つまり、このコールバックは、XSIOnCommandやXSIOnCommandCPPなどのレガシー コールバックとほぼ同じだと言えます。
public class <command_name>
{
public bool Execute( Context in_context )
{
...
}
}
|
CStatus <command_name>_Execute( CRef& in_context )
{
...
}
|
function <command_name>_Execute( in_arg0, in_arg1, in_arg2, ... )
{
...
}
|
def <command_name>_Execute( in_arg0, in_arg1, in_arg2, ... ):
...
|
Function <command_name>_Execute( in_arg0, in_arg1, in_arg2, ... )
...
End Function
|
sub <command_name>_Execute
{
my (@in_args) = @;
}
|
<command_name> は、PluginRegistrar.RegisterCommand の呼び出しで指定されている名前です。この名前に含まれるスペースはアンダースコアに置き換えられます。
| パラメータ | Language | タイプ | 詳細 |
|---|---|---|---|
| in_args | スクリプティング | 引数によって異なります。 | 引数の一覧は、Init コールバックでコマンドに追加された引数に一致します。 引数の実際のタイプは、引数ハンドラ(存在する場合)および呼び出し側から渡される値によって異なります。 |
| in_context | C# | コンテキスト | Context.Source は
Command を返します。 コマンドの引数および戻り値は、コンテキスト属性に格納されます。 |
| in_context | C++ | CRef& | Context オブジェクトへのリファレンス。 コマンドの引数および戻り値は、コンテキスト属性に格納されます。 |
C++ および C# カスタム コマンドは、コマンドの引数と戻り値を取得するためにコンテキスト属性を使用します。
| Attribute | 詳細 |
|---|---|
| Arguments | C# System.Object タイプの配列。 配列の各エレメントを使用する前に、適切なタイプにキャストする必要があります。 C++ CValueArray。 この配列の各エレメントは、引数を格納する CValue オブジェクトであり、ブール、数値、文字列値、単一の Softimage オブジェクト、またはオブジェクトのコレクションなどになります。 「引数を操作する」を参照してください。 |
| ReturnValue | コマンドの戻り値を格納します。 「値を返す」を参照してください。 |
| UndoRequired | C++ API のみ Undo スタックを保持する必要があるかどうかを決定します。 「カスタム コマンドを元に戻す/やり直す」を参照してください。 |
| UndoRedoData | C++ API のみ 現在のアクティビティを Undo スタックに格納し、後で Undo コールバック内で取得することができます。「カスタム コマンドを元に戻す/やり直す」を参照してください。 |
// JScript code generated by the Command Wizard
function XSILoadPlugin( in_reg )
{
in_reg.Author = "sblair";
in_reg.Name = "NewCommand12Plugin";
in_reg.Email = "";
in_reg.URL = "";
in_reg.Major = 1;
in_reg.Minor = 0;
in_reg.RegisterCommand("NewCommand12","NewCommand12");
//RegistrationInsertionPoint - do not remove this line
return true;
}
function XSIUnloadPlugin( in_reg )
{
strPluginName = in_reg.Name;
Application.LogMessage(strPluginName + " has been unloaded.");
return true;
}
function NewCommand12_Init( ctxt )
{
var oCmd;
oCmd = ctxt.Source;
oCmd.Description = "";
oCmd.ReturnValue = true;
var oArgs;
oArgs = oCmd.Arguments;
oArgs.AddWithHandler("Arg0","AnimatableParameters");
oArgs.AddWithHandler("Arg1","Collection");
oArgs.AddWithHandler("Arg2","SingleObj");
oArgs.AddWithHandler("Arg3","Frame");
oArgs.AddWithHandler("Arg4","MarkedParameters");
oArgs.Add("Arg5",siArgumentInput);
return true;
}
function NewCommand12_Execute( Arg0,Arg1,Arg2,Arg3,Arg4,Arg5 )
{
Application.LogMessage("NewCommand12_Execute called");
//
// TODO: Put your command implementation here.
//
return true;
}
|
// C++ code generated by the Command Wizard
#include <xsi_application.h>
#include <xsi_context.h>
#include <xsi_pluginregistrar.h>
#include <xsi_status.h>
#include <xsi_argument.h>
#include <xsi_command.h>
using namespace XSI;
SICALLBACK XSILoadPlugin( PluginRegistrar& in_reg )
{
in_reg.PutAuthor(L"sblair");
in_reg.PutName(L"CmdCppExamplePlugin");
in_reg.PutEmail(L"");
in_reg.PutURL(L"");
in_reg.PutVersion(1,0);
in_reg.RegisterCommand(L"CmdCppExample",L"CmdCppExample");
//RegistrationInsertionPoint - do not remove this line
return CStatus::OK;
}
SICALLBACK XSIUnloadPlugin( const PluginRegistrar& in_reg )
{
CString strPluginName = in_reg.GetName();
Application().LogMessage(strPluginName + L" has been unloaded.");
return CStatus::OK;
}
SICALLBACK CmdCppExample_Init( CRef& in_ctxt )
{
Context ctxt( in_ctxt );
Command oCmd;
oCmd = ctxt.GetSource();
oCmd.PutDescription(L"");
oCmd.EnableReturnValue(true);
ArgumentArray oArgs;
oArgs = oCmd.GetArguments();
oArgs.AddWithHandler(L"Arg0",L"AnimatableParameters");
oArgs.AddWithHandler(L"Arg1",L"Collection");
oArgs.AddWithHandler(L"Arg2",L"SingleObj");
oArgs.AddWithHandler(L"Arg3",L"Frame");
oArgs.AddWithHandler(L"Arg4",L"MarkedParameters");
oArgs.Add(L"Arg5");
return CStatus::OK;
}
SICALLBACK CmdCppExample_Execute( CRef& in_ctxt )
{
Context ctxt( in_ctxt );
CValueArray args = ctxt.GetAttribute(L"Arguments");
CValue Arg0 = args[0];
CValue Arg1 = args[1];
CValue Arg2 = args[2];
CValue Arg3 = args[3];
CValue Arg4 = args[4];
CValue Arg5 = args[5];
Application().LogMessage(L"CmdCppExample_Execute called");
//
// TODO: Put your command implementation here.
//
// Return a value by setting this attribute:
ctxt.PutAttribute( L"ReturnValue", true );
// Return CStatus::Fail if you want to raise a script error
return CStatus::OK;
}
|