- 积分
- 2468
- 明经币
- 个
- 注册时间
- 2004-7-22
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2005-4-20 17:25:00
|
显示全部楼层
我都找到了,代码如下:
'创建正多边形 Public Function AddPolygon(ByVal ptCen As Variant, ByVal number As Integer, ByVal radius As Double, _ Optional width As Double = 0, 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 * PI / 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 Set AddPolygon = objPline End Function
|
|