これコマンドが実行されないのよね。。。
XSILoadPluginでコマンド、プロパティ、メニューを登録します。
(1) [PluginRegister].RegisterCommand(); // _Execute()
(2) [PluginRegister].RegisterProperty(); // _Define(), _DefineLayout(), _PPGEvent()
(3) [PluginRegister].RegisterMenu(); // _Menu_Init()
◆ソース(229行目は無視してください)
// UpdatedOpPlugin // Initial code generated by XSI SDK Wizard // Executed Tue Jan 3 21:53:38 UTC+0900 2012 by xxxx // // Tip: You need to compile the generated code before you can load the plug-in. // After you compile the plug-in, you can load it by clicking Update All in the Plugin Manager. #include#include // Factory #include #include #include #include #include #include #include // CustomProperty #include // Selection #include // Parameter #include // PPGLayout #include // PPGEventContext using namespace XSI; static Application app; static Factory factory = app.GetFactory(); static CustomProperty prop(factory.CreateObject(L"CustomProperty")); XSIPLUGINCALLBACK CStatus XSILoadPlugin( PluginRegistrar& in_reg ) { in_reg.PutAuthor(L"xxxx"); in_reg.PutName(L"UpdatedOpPlugin"); in_reg.PutEmail(L""); in_reg.PutURL(L""); in_reg.PutVersion(1,0); in_reg.RegisterCommand(L"UpdatedOp",L"UpdatedOp"); in_reg.RegisterProperty(L"UpdatedOpProp"); in_reg.RegisterMenu(siMenuTbGetPropertyID,L"UpdatedOp_Menu",false,false); //RegistrationInsertionPoint - do not remove this line return CStatus::OK; } XSIPLUGINCALLBACK CStatus XSIUnloadPlugin( const PluginRegistrar& in_reg ) { CString strPluginName; strPluginName = in_reg.GetName(); Application().LogMessage(strPluginName + L" has been unloaded.",siVerboseMsg); return CStatus::OK; } XSIPLUGINCALLBACK CStatus UpdatedOp_Init( CRef& in_ctxt ) { app.LogMessage(L"on called for UpdatedOp_Init"); Context ctxt( in_ctxt ); Command oCmd; oCmd = ctxt.GetSource(); oCmd.PutDescription(L""); oCmd.EnableReturnValue(true); return CStatus::OK; } XSIPLUGINCALLBACK CStatus UpdatedOpProp_Define(const CRef &in_ctxt) { Context ctxt( in_ctxt ); //CustomProperty prop; Parameter oParam; prop = ctxt.GetSource(); prop.AddParameter(L"numCount", CValue::siInt2, siPersistable | siAnimatable, L"", L"", 0, oParam); return CStatus::OK; } XSIPLUGINCALLBACK CStatus UpdatedOpProp_DefineLayout(const CRef &in_ctxt) { Context ctxt( in_ctxt ); PPGLayout oLayout; PPGItem item; oLayout = ctxt.GetSource(); oLayout.Clear(); oLayout.AddGroup(L"General"); item = oLayout.AddItem(L"numCount", L"Count", siControlNumber); oLayout.EndGroup(); oLayout.AddButton(L"btn_OK", L"Done"); return CStatus::OK; } XSIPLUGINCALLBACK CStatus UpdatedOp_Execute( CRef& in_ctxt ) { Context ctxt( in_ctxt ); CValueArray args = ctxt.GetAttribute(L"Arguments"); Application().LogMessage(L"UpdatedOp_Execute called",siVerboseMsg); // // TODO: Put your command implementation here. prop.PutName(L"Update Op"); Selection oSel = app.GetSelection().GetItem(0); app.LogMessage(oSel.GetAsText(), XSI::siInfoMsg); Parameter oParam; Parameter txtParam; Parameter btnParam; prop.AddParameter(L"Instance", CValue::siString, siReadOnly | siPersistable, L"", L"", L"Instance Here", txtParam); prop.AddParameter(L"Count", CValue::siInt2, siAnimatable | siPersistable | siKeyable, L"", L"", 0, oParam); prop.AddParameter(L"Position", CValue::siInt1, siPersistable, L"", L"", 0, btnParam); PPGLayout oLayout = prop.GetPPGLayout(); oLayout.Clear(); oLayout.AddGroup(L"Update Content"); oLayout.AddItem(L"Instance", L"Target"); oLayout.AddItem(L"Count", 0); oLayout.EndGroup(); CValueArray radio(6); radio[0] = L"Left"; radio[1] = 0; radio[2] = L"Center"; radio[3] = 1; radio[4] = L"Right"; radio[5] = 2; oLayout.AddGroup(L"Position"); oLayout.AddEnumControl(L"Position", radio, L"Change", siControlRadio); oLayout.EndGroup(); oLayout.AddButton(L"done", L""); CValueArray wParam(5); wParam[0] = prop; wParam[1] = L"Update Op"; wParam[2] = (LONG)siModal; wParam[3] = false; CValue ret; app.ExecuteCommand(L"InspectObj", wParam, ret); // // 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; } XSIPLUGINCALLBACK CStatus UpdatedOpProp_PPGEvent(const CRef &in_ctxt) { PPGEventContext ctxt(in_ctxt); PPGEventContext::PPGEvent eventID = ctxt.GetEventID(); switch(eventID) { case (PPGEventContext::siOnInit): { //CustomProperty prop = ctxt.GetSource(); app.LogMessage(L"OnInit called for " + prop.GetFullName()); } break; case (PPGEventContext::siButtonClicked): { CValue btnPressed = ctxt.GetAttribute(L"Button"); app.LogMessage(L"Button Pressed: " + btnPressed.GetAsText()); } break; case (PPGEventContext::siTabChange): break; case (PPGEventContext::siParameterChange): { Parameter param = ctxt.GetSource(); //CustomProperty prop = param.GetParent(); CString name = param.GetScriptName(); app.LogMessage(L"Parameter Changed: " + name); } break; case (PPGEventContext::siOnClosed): { //CustomProperty prop = ctxt.GetSource(); app.LogMessage(L"OnClosed called for " + prop.GetFullName()); } break; } return CStatus::OK; } XSIPLUGINCALLBACK CStatus UpdatedOp_Menu_Init( CRef& in_ctxt ) { Context ctxt( in_ctxt ); Menu oMenu; oMenu = ctxt.GetSource(); MenuItem oNewItem; //oMenu.AddCommandItem(L"UpdatedOp",L"UpdatedOp",oNewItem); CStatus st = oMenu.AddCallbackItem(L"UpdatedOp Sample", L"OnUpdatedOpPropClicked", oNewItem); return st; } XSIPLUGINCALLBACK CStatus OnUpdatedOpPropClicked(const CRef &) { // We use the AddProp command rather than the C++ API // because it logs in the script history and it // automatically takes care of different selection possibilities. Application app; //CustomProperty prop; CValueArray addpropArgs(5) ; addpropArgs[0] = L"UpdatedOpProp"; // Type of Property addpropArgs[3] = L"UpdatedOpProp"; // Name for the Property // At this point you might want to validate what objects // are selected to make sure they make sense for your // property if ( app.GetSelection().GetCount() == 0 ) { // No selection so create the object at the scene root addpropArgs[1] = L"Scene_Root"; } CValue retVal ; CStatus st = app.ExecuteCommand( L"SIAddProp", addpropArgs, retVal ) ; if ( st.Succeeded() ) { // Inspect newly created Property or Properties //(there could be more than one if the selection // contains multiple items) CValueArray resultArray( (CValueArray&)addpropArgs[4] ); CValueArray inspectobjArgs(5) ; inspectobjArgs[0] = resultArray[0] ; app.ExecuteCommand( L"InspectObj", inspectobjArgs, retVal ) ; } return st ; }