|
发表于 2019-7-4 10:27:00
|
显示全部楼层
路过的老师 这个地方为什么是 (i\2)
Public Function AddPolygon(ByVal ptcen As Variant, ByVal number As Integer, ByVal radius As Date, Optional width As Double, Optional angle As Double = 0) As AcadLWPolyline
'定义动态数组
Dim objPline As AcadLWPolyline
Dim ptArr() As Double
'顶点的个数为number,需要2*number个元素来表示
ReDim ptArr(2 * number - 1)
'每条边对应的角度
Dim ang As Double
ang = 2 * 3.1415926 / number
'为点的坐标数组赋值
Dim i As Integer
For i = 0 To 2 * number - 1
If i Mod 2 = 0 Then
ptArr(i) = ptcen(0) + radius * Cos((i \ 2) * ang)
ElseIf i Mod 2 0 Then
ptArr(i) = ptcen(1) + radius * Sin((i \ 2) * ang)
End If
Next i
'创建多段线,并调整其特性
Set objPline = AddLWPline(ptArr, width)
objPline.Closed = True
objPline.Rotate ptcen, angle
objPline.Update
End Function |
|