これコマンドが実行されないのよね。。。
XSILoadPluginでコマンド、プロパティ、メニューを登録します。
(1) [PluginRegister].RegisterCommand(); // _Execute()
(2) [PluginRegister].RegisterProperty(); // _Define(), _DefineLayout(), _PPGEvent()
(3) [PluginRegister].RegisterMenu(); // _Menu_Init()
◆ソース(229行目は無視してください)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 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 <xsi_application.h> #include <xsi_factory.h> // Factory #include <xsi_context.h> #include <xsi_pluginregistrar.h> #include <xsi_status.h> #include <xsi_argument.h> #include <xsi_command.h> #include <xsi_menu.h> #include <xsi_customproperty.h> // CustomProperty #include <xsi_selection.h> // Selection #include <xsi_parameter.h> // Parameter #include <xsi_ppglayout.h> // PPGLayout #include <xsi_ppgeventcontext.h> // 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 ; } </xsi_ppgeventcontext.h></xsi_ppglayout.h></xsi_parameter.h></xsi_selection.h></xsi_customproperty.h></xsi_menu.h></xsi_command.h></xsi_argument.h></xsi_status.h></xsi_pluginregistrar.h></xsi_context.h></xsi_factory.h></xsi_application.h> |
No comments:
Post a Comment