|
马上注册,结交更多同行朋友,交流,分享,学习。
您需要 登录 才可以下载或查看,没有帐号?注册
x
不知道什么原因,现在用Inventor2008二次开发,只要Inventor2008重新启动一次,菜单就会重复加载一次。导致二次开发的菜单越来越多。求救呀!
我的代码如下:
Public Function ssss()
Dim oControlDefinitions As ControlDefinitions
Set oControlDefinitions = ThisApplication.CommandManager.ControlDefinitions
Set oButtonDefinition1 = oControlDefinitions.AddButtonDefinition( _
"Button 1", "invrSampleCommand1", _
kQueryOnlyCmdType, "CLSID of the AddIn", _
"This is button 1.", "Button 1")
' Create two more button definitions. One with an icon and one without.
Set oButtonDefinition2 = oControlDefinitions.AddButtonDefinition( _
"Button 2", "invrSampleCommand2", _
kQueryOnlyCmdType, "CLSID of the AddIn", _
"This is button 2.", "Button 2")
Set oButtonDefinition3 = oControlDefinitions.AddButtonDefinition( _
"Button 3", "invrSampleCommand3", _
kQueryOnlyCmdType, "CLSID of the AddIn", _
"This is button 3.", "Button 3")
' Get the part environment object.
Dim oUIManager As UserInterfaceManager
Dim oPartEnv As Environment
Set oUIManager = ThisApplication.UserInterfaceManager
Set oPartEnv = oUIManager.Environments.Item("PMxPartEnvironment")
' Get the command bar that is used for the part menu.
Dim oPartMenuCB As CommandBar
Set oPartMenuCB = oPartEnv.DefaultMenuBar
' Create a command bar of a pop-up type for a flyout.
Dim oFlyOutCmdBar As CommandBar
Set oFlyOutCmdBar = oUIManager.CommandBars.Add("More Commands", _
"FlyoutCmdBar", kPopUpCommandBar, "CLSID of the AddIn")
' Add two buttons to the fly-out command bar.
Call oFlyOutCmdBar.Controls.AddButton(oButtonDefinition2)
Call oFlyOutCmdBar.Controls.AddButton(oButtonDefinition3)
' Create a command bar of a pop-up type for a menu popup.
Dim oMenuPopupCmdBar As CommandBar
Set oMenuPopupCmdBar = oUIManager.CommandBars.Add("Test", _
"MenuPopupCmdBar", kPopUpCommandBar, "CLSID of the AddIn")
' Add a command to the menu pop-up.
Call oMenuPopupCmdBar.Controls.AddButton(oButtonDefinition1)
' Add the fly-out to the menu pop-up.
Call oMenuPopupCmdBar.Controls.AddPopup(oFlyOutCmdBar)
' Get the index of the Help control.
Dim HelpIndex As Long
HelpIndex = oPartMenuCB.Controls.Item("AppHelpMenu").index
' Add the menu popup to part menu before the Help control.
Call oPartMenuCB.Controls.AddPopup(oMenuPopupCmdBar, HelpIndex)
End Function |
|