CAD 五角星绘制
程序代码: | [ 复制代码到剪贴板 ] |
'**********************************************************************************************
'五角星绘制****************************************五角星绘制*************************************
Sub 五角星()
Dim PO As Variant
Dim P(0 To 19) As Double
Dim Max As Variant
Dim Min As Variant
On Error Resume Next
'在存储图形范围内绘制五角星,当然还可以制定其他矩形区域的两个角点
Max = ThisDrawing.GetVariable("extmax")
Min = ThisDrawing.GetVariable("extmin")
'从下面绘制的两个点看得出来,这个点并不是屏幕的绘图区域.
'ThisDrawing.ModelSpace.AddPoint Max
'ThisDrawing.ModelSpace.AddPoint Min
'Rectangle Max, Min
ThisDrawing.Utility.InitializeUserInput 1, ""
PO = ThisDrawing.Utility.GetPoint(, "插入点:")
Dim R1 As Double, R2 As Double
R1 = P2PDistance(Max, Min) / 2
Dim PI As Double
PI = Atn(1) * 4
'三角形定理:a/Sin(A)=b/Sin(B)=c/Sin(C)
R2 = R1 * Sin(18 * PI / 180) / Sin(126 * PI / 180)
Dim i As Integer
'定点坐标计算方法参见文件夹下的说明。
For i = 0 To 4
P(2 * 2 * i) = PO(0) + R1 * Cos((18 + 72 * i) * PI / 180):
P(2 * 2 * i + 1) = PO(1) + R1 * Sin((18 + 72 * i) * PI / 180)
P(2 * (2 * i + 1)) = PO(0) + R2 * Cos((54 + 72 * i) * PI / 180):
P(2 * (2 * i + 1) + 1) = PO(1) + R2 * Sin((54 + 72 * i) * PI / 180)
Next
Dim PL As AcadLWPolyline
Set PL = ThisDrawing.ModelSpace.AddLightWeightPolyline(P)
PL.color = acRed
PL.Closed = True
For i = 0 To 9
ThisDrawing.ModelSpace.AddLine PO, Point3D(P(2 * i), P(2 * i + 1), 0)
Next i
End Sub
'五角星绘制****************************************五角星绘制*************************************
Sub 五角星()
Dim PO As Variant
Dim P(0 To 19) As Double
Dim Max As Variant
Dim Min As Variant
On Error Resume Next
'在存储图形范围内绘制五角星,当然还可以制定其他矩形区域的两个角点
Max = ThisDrawing.GetVariable("extmax")
Min = ThisDrawing.GetVariable("extmin")
'从下面绘制的两个点看得出来,这个点并不是屏幕的绘图区域.
'ThisDrawing.ModelSpace.AddPoint Max
'ThisDrawing.ModelSpace.AddPoint Min
'Rectangle Max, Min
ThisDrawing.Utility.InitializeUserInput 1, ""
PO = ThisDrawing.Utility.GetPoint(, "插入点:")
Dim R1 As Double, R2 As Double
R1 = P2PDistance(Max, Min) / 2
Dim PI As Double
PI = Atn(1) * 4
'三角形定理:a/Sin(A)=b/Sin(B)=c/Sin(C)
R2 = R1 * Sin(18 * PI / 180) / Sin(126 * PI / 180)
Dim i As Integer
'定点坐标计算方法参见文件夹下的说明。
For i = 0 To 4
P(2 * 2 * i) = PO(0) + R1 * Cos((18 + 72 * i) * PI / 180):
P(2 * 2 * i + 1) = PO(1) + R1 * Sin((18 + 72 * i) * PI / 180)
P(2 * (2 * i + 1)) = PO(0) + R2 * Cos((54 + 72 * i) * PI / 180):
P(2 * (2 * i + 1) + 1) = PO(1) + R2 * Sin((54 + 72 * i) * PI / 180)
Next
Dim PL As AcadLWPolyline
Set PL = ThisDrawing.ModelSpace.AddLightWeightPolyline(P)
PL.color = acRed
PL.Closed = True
For i = 0 To 9
ThisDrawing.ModelSpace.AddLine PO, Point3D(P(2 * i), P(2 * i + 1), 0)
Next i
End Sub
[本日志由 田草 于 2007-01-26 01:57 PM 编辑]
|
暂时没有评论
发表评论 - 不要忘了输入验证码哦! |