VBA创建菜单问题。请高手指导一下
Option ExplicitSub AddASubMenu()<BR> Dim currMenuGroup As AcadMenuGroup<BR> Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)<BR> <BR> Dim newMenu As AcadPopupMenu<BR> Set newMenu = currMenuGroup.Menus.Add("自动绘图" & Chr(Asc("&")))<BR> <BR> <BR> Dim macro As String<BR> macro = Chr(vbKeyEscape) + Chr(vbKeyEscape)
Dim menuItemDraw As AcadPopupMenu<BR> Set menuItemDraw = newMenu.AddSubMenu(newMenu.Count + 1, Chr(Asc("画图")))<BR> Dim subMenuItemPoint As AcadPopupMenuItem<BR> Set subMenuItemPoint = menuItemDraw.AddMenuItem(menuItemDraw.Count + 1, Chr(Asc("&")) & "点", macro & "_point ")<BR> Dim subMenuItemLine As AcadPopupMenuItem<BR> Set subMenuItemLine = menuItemDraw.AddMenuItem(menuItemDraw.Count + 1, Chr(Asc("&")) & "直线", macro & "_line ")<BR> Dim subMenuItemPolyline As AcadPopupMenuItem<BR> Set subMenuItemPolyline = menuItemDraw.AddMenuItem(menuItemDraw.Count + 1, Chr(Asc("&")) & "多段线", macro & "_polyline ")<BR> Dim subMenuItemEllipseRec As AcadPopupMenuItem<BR> Set subMenuItemEllipseRec = menuItemDraw.AddMenuItem(menuItemDraw.Count + 1, Chr(Asc("&")) & "椭圆", macro & "_ellipserec ")<BR> Dim subMenuItemSpline As AcadPopupMenuItem<BR> Set subMenuItemSpline = menuItemDraw.AddMenuItem(menuItemDraw.Count + 1, Chr(Asc("&")) & "样条曲线", macro & "_spline ")<BR> Dim subMenuItemArc As AcadPopupMenuItem<BR> Set subMenuItemArc = menuItemDraw.AddMenuItem(menuItemDraw.Count + 1, Chr(Asc("&")) & "曲线", macro & "_arc ")<BR> Dim subMenuItemCircle As AcadPopupMenuItem<BR> Set subMenuItemCircle = menuItemDraw.AddMenuItem(menuItemDraw.Count + 0, Chr(Asc("&")) & "圆", macro & "_circle ")<BR> Set subMenuItemCircle = menuItemDraw.AddMenuItem(menuItemDraw.Count + 1, _<BR> Chr(Asc("&")), macro & "-vbarun" + Chr(32) + "ThisDrawing.DrawCircle" + Chr(32))<BR> newMenu.InsertInMenuBar (ThisDrawing.Application.MenuBar.Count + 1)<BR> End Sub
End Sub<BR>Sub drawpoint()<BR>Dim location(0 To 2) As Double<BR>location(0) = 200: location(1) = 200: location(2) = 0<BR>ThisDrawing.ModelSpace.AddPoint location<BR>End Sub
Sub DrawLine()<BR>Dim pt1(2) As Double<BR>Dim pt2(2) As Double<BR>pt1(0) = 100: pt1(1) = 50: pt1(2) = 0<BR>pt2(0) = 300: pt2(1) = 100: pt2(2) = 0<BR> ThisDrawing.ModelSpace.AddLine pt1, pt2
Sub drawCircle()<BR>Dim ptcen(0 To 2) As Double<BR>ptcen(0) = 200<BR>ptcen(1) = 200<BR>ptcen(2) = 0<BR>ThisDrawing.ModelSpace.AddCircle ptcen, 60<BR>ZoomExtents
End Sub
Sub DrawPolyline()<BR>Dim pt1(2) As Double<BR>Dim pt2(2) As Double<BR>Dim pt3(2) As Double
pt1(0) = 100: pt1(1) = 100: pt1(2) = 0<BR>pt2(0) = 300: pt2(1) = 150: pt2(2) = 0<BR>pt3(0) = 400: pt3(1) = 200: pt3(2) = 0<BR> <BR> ThisDrawing.ModelSpace.AddPolyline pt1, pt2, pt3<BR>End Sub<BR>想做成在下拉菜单中点击一个基本图对象自动绘出一个相应的图。多段线,样条曲线,椭圆,圆弧代码写不出来了 恳请高手指点一下。 多段线部分也调试不出
还有请问如何将指令对应起来? 我现在的这个程序点击圆无法输出圆形,而最下面出现空白一块点击后绘出圆 Dim curMenuGroup As AcadMenuGroup<BR>Set curMenuGroup = Application.MenuGroups.Item(0)<BR>Dim newMenu As AcadPopupMenu<BR>'******************************************************************************<BR>Set newMenu = curMenuGroup.Menus.Add("标注2(&U)")<BR>'声明菜单项<BR>Dim userMenuItem As AcadPopupMenuItem<BR>'定义宏变量<BR>Dim strMacro As String<BR>'高程 菜单<BR>strMacro = "-vbarun SpiritVale.dvb!modSpiritVale.Biaogao "<BR>Set userMenuItem = newMenu.AddMenuItem(newMenu.Count, "高程(&G)", strMacro)<BR>userMenuItem.HelpString = "指定比例尺及高程点标出高程"
curMenuGroup.Menus.InsertMenuInMenuBar "标注2(&U)", ""
页:
[1]