将下列程序拷到CAD中“工具” “选项”“宏”“VisualBasic编辑器”里,运行即可。
Sub jkx()
Rem 绘制渐开线,By Sdh,2006-6-8
Dim d As Double '节圆直径
Dim r As Double '节圆半径
Dim A As Double '总展开角度
Dim Ai As Double '展开角度
Dim Li As Double '展开弧长
d = 100
A = 360
r = d / 2
Dim Pnt1(2) As Double
Dim Pnt2(2) As Double
Dim PntLst() As Double, N As Integer
ThisDrawing.ModelSpace.AddCircle Pnt1, r
For Ai = 0 To A * Atn(1) / 45# Step Atn(1) / 45#
Li = r * Ai
Pnt1(0) = r * Sin(Ai)
Pnt1(1) = r * Cos(Ai)
Pnt2(0) = Pnt1(0) - Li * Cos(-Ai)
Pnt2(1) = Pnt1(1) - Li * Sin(-Ai)
ThisDrawing.ModelSpace.AddLine Pnt1, Pnt2
N = N + 1
ReDim Preserve PntLst(N * 2 - 1)
PntLst(N * 2 - 2) = Pnt2(0)
PntLst(N * 2 - 1) = Pnt2(1)
Next
If N > 1 Then
ThisDrawing.ModelSpace.AddLightWeightPolyline PntLst
End If
End Sub