- 积分
- 297
- 明经币
- 个
- 注册时间
- 2005-6-3
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
Option Explicit
Sub AddASubMenu() Dim currMenuGroup As AcadMenuGroup Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0) Dim newMenu As AcadPopupMenu Set newMenu = currMenuGroup.Menus.Add("自动绘图" & Chr(Asc("&"))) Dim macro As String macro = Chr(vbKeyEscape) + Chr(vbKeyEscape)
Dim menuItemDraw As AcadPopupMenu Set menuItemDraw = newMenu.AddSubMenu(newMenu.Count + 1, Chr(Asc("画图"))) Dim subMenuItemPoint As AcadPopupMenuItem Set subMenuItemPoint = menuItemDraw.AddMenuItem(menuItemDraw.Count + 1, Chr(Asc("&")) & "点", macro & "_point ") Dim subMenuItemLine As AcadPopupMenuItem Set subMenuItemLine = menuItemDraw.AddMenuItem(menuItemDraw.Count + 1, Chr(Asc("&")) & "直线", macro & "_line ") Dim subMenuItemPolyline As AcadPopupMenuItem Set subMenuItemPolyline = menuItemDraw.AddMenuItem(menuItemDraw.Count + 1, Chr(Asc("&")) & "多段线", macro & "_polyline ") Dim subMenuItemEllipseRec As AcadPopupMenuItem Set subMenuItemEllipseRec = menuItemDraw.AddMenuItem(menuItemDraw.Count + 1, Chr(Asc("&")) & "椭圆", macro & "_ellipserec ") Dim subMenuItemSpline As AcadPopupMenuItem Set subMenuItemSpline = menuItemDraw.AddMenuItem(menuItemDraw.Count + 1, Chr(Asc("&")) & "样条曲线", macro & "_spline ") Dim subMenuItemArc As AcadPopupMenuItem Set subMenuItemArc = menuItemDraw.AddMenuItem(menuItemDraw.Count + 1, Chr(Asc("&")) & "曲线", macro & "_arc ") Dim subMenuItemCircle As AcadPopupMenuItem Set subMenuItemCircle = menuItemDraw.AddMenuItem(menuItemDraw.Count + 0, Chr(Asc("&")) & "圆", macro & "_circle ") Set subMenuItemCircle = menuItemDraw.AddMenuItem(menuItemDraw.Count + 1, _ Chr(Asc("&")), macro & "-vbarun" + Chr(32) + "ThisDrawing.DrawCircle" + Chr(32)) newMenu.InsertInMenuBar (ThisDrawing.Application.MenuBar.Count + 1) End Sub
End Sub Sub drawpoint() Dim location(0 To 2) As Double location(0) = 200: location(1) = 200: location(2) = 0 ThisDrawing.ModelSpace.AddPoint location End Sub
Sub DrawLine() Dim pt1(2) As Double Dim pt2(2) As Double pt1(0) = 100: pt1(1) = 50: pt1(2) = 0 pt2(0) = 300: pt2(1) = 100: pt2(2) = 0 ThisDrawing.ModelSpace.AddLine pt1, pt2
Sub drawCircle() Dim ptcen(0 To 2) As Double ptcen(0) = 200 ptcen(1) = 200 ptcen(2) = 0 ThisDrawing.ModelSpace.AddCircle ptcen, 60 ZoomExtents
End Sub
Sub DrawPolyline() Dim pt1(2) As Double Dim pt2(2) As Double Dim pt3(2) As Double
pt1(0) = 100: pt1(1) = 100: pt1(2) = 0 pt2(0) = 300: pt2(1) = 150: pt2(2) = 0 pt3(0) = 400: pt3(1) = 200: pt3(2) = 0 ThisDrawing.ModelSpace.AddPolyline pt1, pt2, pt3 End Sub 想做成在下拉菜单中点击一个基本图对象自动绘出一个相应的图。多段线,样条曲线,椭圆,圆弧代码写不出来了 恳请高手指点一下。 多段线部分也调试不出
|
|