您的位置:网站首页 > CAD新闻

AutoCAD利用VBA宏绘制多重平行线

时间:2012-01-31 17:59:30 来源:未知

多重平行线有多种多样的样式,主要用于绘制像墙之类的的平行线的场合,当你使用多种的标准绘制直线时,需要另外一条线来设置距离。

绘制多重平行线的代码如下。

Sub mylines()
    Dim multilineobj As AcadMLine
    Dim vertices(0 To 17) As Double
    vertices(0) = 3: vertices(1) = 3: vertices(2) = 0
    vertices(3) = 5: vertices(4) = 6: vertices(5) = 0
    vertices(6) = 3: vertices(7) = 8: vertices(8) = 0
    vertices(9) = 7: vertices(10) = 5: vertices(11) = 0
    vertices(12) = 5: vertices(13) = 6: vertices(14) = 0
    vertices(15) = 3: vertices(16) = 3: vertices(17) = 0
    Set multilineobj = ThisDrawing.ModelSpace.AddMLine(vertices)
End Sub

代码完。

首先声明mulines函数,定义AcadLine图元实例,定义双精度型数组作为Mline的顶点,最后利用AddMLine方法添加多重线。