プラグインのロード後に、初めてコマンドが起動されると発生します。 コマンドの戻り値と引数を指定します。
自己インストール カスタム コマンドは、Softimage の他のコマンド(カスタムおよびネイティブの両方)と異なり、Softimage のロード時には Softimage コマンド マップに追加され、Softimage の終了時や明示的にアンインストールされたときには削除されます。 このため、自己インストール コマンドは、Init コールバック内部で定義する必要があります。
public class <command_name>
{
public bool Init( Context in_context )
{
...
}
} |
CStatus <command_name>_Init( CRef& in_context )
{
...
} |
function <command_name>_Init( in_context )
{
...
} |
def <command_name>_Init( in_context ): ... |
Function <command_name>_Init( in_context ) ... End Function |
sub <command_name>_Init
{
my $in_context = shift;
} |
<command_name> は、PluginRegistrar.RegisterCommand の呼び出しで指定されている名前です。この名前に含まれるスペースはアンダースコアに置き換えられます。
| パラメータ | Language | タイプ | 説明 |
|---|---|---|---|
| in_context | スクリプティングおよび C# | コンテキスト | Context.Source は Command を返します。 |
| C++ | CRef& | Context オブジェクトへのリファレンス。 Context::GetSource は Command を返します。 |
// JScript code generated by the Command Wizard
function XSILoadPlugin( in_reg )
{
in_reg.Author = "sblair";
in_reg.Name = "My_JsCommandPlugin";
in_reg.Email = "";
in_reg.URL = "";
in_reg.Major = 1;
in_reg.Minor = 0;
in_reg.RegisterCommand("My_JsCommand","My_JsCommand");
//RegistrationInsertionPoint - do not remove this line
return true;
}
function My_JsCommand_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.Add("Arg5",siArgumentInput);
return true;
}
function My_JsCommand_Execute( Arg0,Arg1,Arg2,Arg5 )
{
Application.LogMessage("My_JsCommand_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;
} |