加载和删除菜单
是否可以加载菜单(*.mnu文件)或用代码删除它们?考虑到*。mnu文件位于支持路径中。您可以在代码中构建菜单。检查custom_菜单。dvb来自{ACAD\U DIR}\Sample\VBA\VBAIDEMenu\。 要知道,2007年处理菜单的方式非常不同
适用于2004年的代码不适用于2007年,2007年的菜单很难使用。 哦,太好了……我本来应该写一个适用于所有用户的程序,但现在我发现这是不可能的。。。 不是不可能,只是有很多乐趣 ;那么你想做什么,也许我们能帮上忙 我知道用Lisp代码回答VBA主题很有趣,但我再次知道Lendge是Knolenge,不应该被隐藏()。
我找到了一种轻松加载和删除菜单的方法:
首先,我将filedia系统变量设置为0,以便通过代码操作AutoCAD。我使用MENULOAD命令加载我想要的菜单,然后使用MENULOAD将其删除
恢复filedia值和#039;就是这样
嗯,不……原因是我仍然没有';t在菜单行中插入了菜单下拉菜单。有人知道我如何用代码做到这一点吗?
Sub Example_InsertInMenuBar()
' This example creates a new menu called TestMenu and inserts a menu item
' into it. The menu is then displayed on the menu bar.
' To remove the menu after execution of this macro, use the Customize Menu
' option from the Tools menu.
Dim currMenuGroup As acadMenuGroup
Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)
' Create the new menu
Dim newMenu As AcadPopupMenu
Set newMenu = currMenuGroup.Menus.Add("TestMenu")
' Add a menu item to the new menu
Dim newMenuItem As AcadPopupMenuItem
Dim openMacro As String
' Assign the macro string the VB equivalent of "ESC ESC _open "
openMacro = Chr(3) & Chr(3) & Chr(95) & "open" & Chr(32)
Set newMenuItem = newMenu.AddMenuItem(newMenu.count + 1, "Open", openMacro)
' Display the menu on the menu bar
newMenu.InsertInMenuBar (ThisDrawing.Application.MenuBar.count + 1)
End Sub
并删除Sub Example_RemoveFromMenuBar()
' This example creates a new menu called TestMenu and inserts a menu item
' into it. The menu is then displayed on the menu bar, and then
' removed from the menu bar.
Dim currMenuGroup As acadMenuGroup
Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)
' Create the new menu
Dim newMenu As AcadPopupMenu
Set newMenu = currMenuGroup.Menus.Add("TestMenu")
' Add a menu item to the new menu
Dim newMenuItem As AcadPopupMenuItem
Dim openMacro As String
' Assign the macro string the VB equivalent of "ESC ESC _open "
openMacro = Chr(3) & Chr(3) & Chr(95) & "open" & Chr(32)
Set newMenuItem = newMenu.AddMenuItem(newMenu.count + 1, "Open", openMacro)
' Display the menu on the menu bar
newMenu.InsertInMenuBar (ThisDrawing.Application.MenuBar.count + 1)
GoSub QUERYMENU
' Remove the menu from the menu bar
newMenu.RemoveFromMenuBar
GoSub QUERYMENU
Exit Sub
QUERYMENU:
If newMenu.OnMenuBar Then
MsgBox "The menu called " & newMenu.name & " is on the menu bar."
Else
MsgBox "The menu called " & newMenu.name & " is not on the menu bar."
End If
Return
End Sub 是的,我知道我知道…我今天下午在贝鲁的时候在VBA帮助中展示了这个。但是我找到了一个更简单的方法!使用AutoLISP!这里是:
(menucmd“P12=+MyMenuGroup.MyMenuName”)
将从指定菜单组(MyMenugroup)加载指定菜单(MyMenuName),该菜单组应已使用MENLOAD命令加载。在上面的示例中,菜单添加到菜单行上的位置12之前。因此,只有3行,可以加载、指定pozition和卸载菜单!
页:
[1]