菜单的创建
Module Module1Public Acadapp As AutoCAD.AcadApplication
Sub 连接AutoCAD()
On Error Resume Next
Acadapp = GetObject(, "AutoCAD.Application")
If Err.Number Then
Err.Clear()
Acadapp = CreateObject("AutoCAD.Application")
If Err.Number Then
MsgBox("不能运行AutoCAD,请检查是否安装了AutoCAD")
Exit Sub
End If
End If
Acadapp.Visible = True '界面可视
Acadapp.WindowState = AutoCAD.AcWindowState.acMax '界面最大化
AppActivate(Acadapp.Caption) '显示AutoCAD界面
End Sub
Sub main()
Call 连接AutoCAD()
Dim currMenuGroup As AutoCAD.AcadMenuGroup
currMenuGroup = Acadapp.Application.MenuGroups.Item(0)
'创建新菜单
Dim NewMenu As AutoCAD.AcadPopupMenu
NewMenu = currMenuGroup.Menus.Add("个性化菜单项(&B)")
'注意,若AutoCAD菜单条已有一个同名菜单,则会报错。
'在新菜单上添加菜单项
Dim newMenuItem1 As AutoCAD.AcadPopupMenuItem
Dim newMenuItem2 As AutoCAD.AcadPopupMenuItem
Dim newMenuItem3 As AutoCAD.AcadPopupMenuItem
Dim newMenuItem4 As AutoCAD.AcadPopupMenuItem
Dim newMenuItem5 As AutoCAD.AcadPopupMenuItem
Dim openMacro1 As String
Dim openMacro2 As String
Dim openMacro3 As String
Dim openMacro4 As String
Dim openMacro5 As String
'定义菜单宏
openMacro1 = Chr(3) & Chr(3) & "shell" & Chr(13) & "齿轮结构参数化三维造型.exe" & Chr(13)
openMacro2 = Chr(3) & Chr(3) & "shell" & Chr(13) & "斜齿轮.exe" & Chr(13)
openMacro3 = Chr(3) & Chr(3) & "shell" & Chr(13) & "尺寸公差自动标注.exe" & Chr(13)
openMacro4 = Chr(3) & Chr(3) & "shell" & Chr(13) & "形位公差自动标注.exe" & Chr(13)
openMacro5 = Chr(3) & Chr(3) & "shell" & Chr(13) & "Access数据库管理图形.exe" & Chr(13)
'创建菜单项
newMenuItem1 = NewMenu.AddMenuItem(NewMenu.Count + 1, "齿轮结构参数化三维造型(&A)", openMacro1)
newMenuItem2 = NewMenu.AddMenuItem(NewMenu.Count + 1, "斜齿轮(&C)", openMacro1)
newMenuItem3 = NewMenu.AddMenuItem(NewMenu.Count + 1, "尺寸公差自动标注(&D)", openMacro1)
newMenuItem4 = NewMenu.AddMenuItem(NewMenu.Count + 1, "形位公差自动标注(&E)", openMacro1)
newMenuItem5 = NewMenu.AddMenuItem(NewMenu.Count + 1, "Access数据库管理图形(&F)", openMacro1)
'在菜单条上显示菜单
NewMenu.InsertInMenuBar(Acadapp.Application.MenuBar.Count + 1)
Acadapp = Nothing
End Sub
End Module
拿来试试,表中格式符号可能有点麻烦。 能介绍一下这是什么东西吗?该如何操作呢? 看这个头都大了
能解释一下干嘛的吗
页:
[1]