要旋转对象,请使用该对象的 Rotate 方法。这个方法需要输入一个基点和一个旋转角度。基点是由三个双精度数组成的变量数组。这些双精度数代表一个三维 WCS 坐标,用于指定旋转轴所通过的点。旋转角度则以弧度指定,此角度确定对象绕基点、相对于当前位置旋转的距离。
有关旋转对象的详细信息,请参见《用户手册》中的“旋转对象”。
本例创建一条闭合的优化多段线,然后将该多段线绕基点 (4,4.25,0) 旋转 45 度。
Sub Ch4_RotatePolyline()
' 创建多段线
Dim plineObj As AcadLWPolyline
Dim points(0 To 11) As Double
points(0) = 1: points(1) = 2
points(2) = 1: points(3) = 3
points(4) = 2: points(5) = 3
points(6) = 3: points(7) = 3
points(8) = 4: points(9) = 4
points(10) = 4: points(11) = 2
Set plineObj = ThisDrawing.ModelSpace. _
AddLightWeightPolyline(points)
plineObj.Closed = True
ZoomAll
' 定义绕点 (4,4.25,0) 旋转
' 45 度
Dim basePoint(0 To 2) As Double
Dim rotationAngle As Double
basePoint(0) = 4: basePoint(1) = 4.25: basePoint(2) = 0
rotationAngle = 0.7853981 ' 45 degrees
' 旋转多段线
plineObj.Rotate basePoint, rotationAngle
plineObj.Update
End Sub