AutoVBA在绘图空间创建LINE对象,代码如下。
Public Sub creatline()
Dim mylineobject As AcadLine
Dim startpoint(0 To 2) As Double
Dim endpoint(0 To 2) As Double
startpoint(0) = 1
startpoint(1) = 3
startpoint(2) = 2
endpoint(0) = 4
endpoint(1) = 5
endpoint(2) = 4
Set mylineobject = ThisDrawing.ModelSpace.AddLine(startpoint, endpoint)
End Sub
代码完。
定义一个创建直线的函数,指定起点和终点,然后将其添加到绘图空间。