绘制矩形的子程序是错误的,点坐标应该是二维的,不是三维的。
LightweightPolyline 对象:变体为 OCS 坐标系统的二维点数组。
Polyline 对象:变体为三维点数组, X 和 Y 坐标为 OCS 坐标系统; Z 坐标忽略。
'绘制矩形的子程序(经过验证,2006版CAD)
Sub box(x1, y1, x2, y2)
Dim plineObj As AcadLWPolyline
Dim points(0 To 7) As Double
'dim M as integer '行数
'dim N as integer '列数
' 定义多段线的点
points(0) = x1: points(1) = y1
points(2) = x2: points(3) = y1
points(4) = x2: points(5) = y2
points(6) = x1: points(7) = y2
'在模型空间中创建一个多段线对象
Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
plineObj.Closed = True
End Sub