|
发表于 2020-9-4 13:26:00
|
显示全部楼层
Public Function AddPolygon(ByVal centerpoint As Variant, ByVal sideCount As Double, ByVal radius As Double, Optional width As Double = 0, Optional angle As Double = 0) As AcadLWPolyline
Dim math As New clsmath
Dim sideAngle As Double
sideAngle = (2 * math.PI()) / sideCount
Dim verts As New cls2dPointArray
Dim i As Integer
Dim point(0 To 1) As Double
For i = 0 To 2 * (sideCount - 1)
If i Mod 2 = 0 Then
point(0) = centerpoint(0) + radius * Sin((i / 2) * sideAngle)
verts.Append point
Else
point(1) = centerpoint(1) + radius * Cos((i / 2) * sideAngle)
End If
Next i
Set AddPolygon = AddLWPolyline(verts.ToArray(), True, width)
AddPolygon.Rotate centerpoint, angle
AddPolygon.Update
End Function |
|