Public Sub CreateMenu() On Error Resume Next '用AutoCAD菜单组的第一项创建一个菜单组 Dim CurMenuGroup As Object Set CurMenuGroup = ThisDrawing.Application.MenuGroups.Item(0) '创建一个名为“CAD增强插件”的菜单项,设S为加速键 Dim NewMenu As Object Set NewMenu = CurMenuGroup.Menus.Add("CAD增强插件(" + Chr(Asc("&")) + "S)") '确定选择项的宏 Dim FlowMacro As String '为宏分配命令 '即VBA中的 ESC ESC 设计流程 FlowMacro = Chr(3) & Chr(3) & "(vl-vbarun " & Chr(34) & "DefPipeSize" & Chr(34) & ")" & Chr(13) '添加选择项到CAD增强插件菜单项中 Dim FlowMenuItem As Object Dim SepaMenuItem As Object '分隔符 Set FlowMenuItem = NewMenu.AddMenuItem(NewMenu.Count + 1, Chr(Asc("&")) + "插入页码", FlowMacro) Set SepaMenuItem = NewMenu.AddSeparator(NewMenu.Count + 1) '创建子菜单 Dim SingleMenu As Object Set SingleMenu = NewMenu.AddSubMenu(NewMenu.Count + 1, "横断面修改") '将选择项添加到子菜单中 Dim SubMenuItem As Object Dim SubMacro As String SubMacro = Chr(3) & Chr(3) & "(vl-vbarun " & Chr(34) & "Start_HdmBz" & Chr(34) & ")" & Chr(13) Set SubMenuItem = SingleMenu.AddMenuItem(SingleMenu.Count + 1, "横断面高程标注 ", SubMacro) Set SepaMenuItem = NewMenu.AddSeparator(NewMenu.Count + 1) '即VBA中的 ESC ESC 设计流程 FlowMacro = Chr(3) & Chr(3) & "(vl-vbarun " & Chr(34) & "AboutUs" & Chr(34) & ")" & Chr(13) Set FlowMenuItem = NewMenu.AddMenuItem(NewMenu.Count + 1, Chr(Asc("&")) + "关于", FlowMacro) FlowMacro = Chr(3) & Chr(3) & "(vl-vbarun " & Chr(34) & "SetOption" & Chr(34) & ")" & Chr(13) Set FlowMenuItem = NewMenu.AddMenuItem(NewMenu.Count + 1, Chr(Asc("&")) + "设置", FlowMacro) '在AutoCAd菜单条上显示新创建的菜单 NewMenu.InsertInMenuBar (ThisDrawing.Application.MenuBar.Count + 1) End Sub
'拷别人的,自己换用相应的方法就行了 |