明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1856|回复: 1

Spline应用一例

[复制链接]
发表于 2009-9-29 12:01:00 | 显示全部楼层 |阅读模式


程序如下
  1. Sub lll()
  2.    Dim R, R1, H, Dn, THK, Dn1, THK1
  3.    Dim Alfa, baseAlfa
  4.    Dim Pt1(2) As Double, Pt2(2) As Double
  5.    
  6.    Dim oLine As AcadLine
  7.    Dim oDivide
  8.    Dn = 2400: THK = 18
  9.    Dn1 = 530: THK1 = 18
  10.    R = Dn / 2 - THK
  11.    Dim oCircle As AcadCircle
  12.    'Set oCircle = ThisDrawing.ModelSpace.AddCircle(Pt1, R)
  13.    'Debug.Print oCircle.Circumference;
  14.    R1 = Dn1 / 2
  15.    Set oCircle = ThisDrawing.ModelSpace.AddCircle(Pt1, R1)
  16.    'Debug.Print oCircle.Circumference;
  17.    H = 250
  18.    Dim Pi
  19.    Pi = Atn(1) * 4
  20.    oDivide = 10
  21.    Dim splinePt() As Double, oSpline As AcadSpline
  22.    ReDim splinePt((360 / oDivide) * 3 + 2)
  23.    baseAlfa = oDivide * Pi / 180
  24.    Pt1(0) = 0
  25.    Pt2(0) = 2 * R1 * Pi
  26.    Set oLine = ThisDrawing.ModelSpace.AddLine(Pt1, Pt2)
  27.    Dim StartTangent, EndTangent
  28.    For n = 0 To 360 / oDivide
  29.      Alfa = n * baseAlfa
  30.      x = R1 * Cos(Alfa)
  31.      Pt1(0) = n * R1 * baseAlfa
  32.      Pt2(0) = Pt1(0)
  33.      ln = H + (R - Sqr(R ^ 2 - x ^ 2))
  34.      Pt2(0) = Pt1(0)
  35.      Pt2(1) = ln
  36.      'Debug.Print baseAlfa, Alfa, "x:" & Round(x, 5), "n=" & n, "Ln=" & ln
  37.      If n = 0 Then
  38.        StartTangent = Pt2
  39.      End If
  40.      Set oLine = ThisDrawing.ModelSpace.AddLine(Pt1, Pt2)
  41.      For jj = 0 To 2
  42.        splinePt(n * 3 + jj) = Pt2(jj)
  43.      Next jj
  44.    Next n
  45.    EndTangent = Pt2
  46.     Dim startTan(0 To 2) As Double
  47.     Dim endTan(0 To 2) As Double
  48.     'startTan(0) = 0: startTan(1) = 0.5: startTan(2) = 0
  49.     'endTan(0) = 0.5: endTan(1) = -0.5: endTan(2) = 0
  50.    Set oSpline = ThisDrawing.ModelSpace.AddSpline(splinePt, startTan, endTan)
  51. End Sub

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2009-10-24 14:46:00 | 显示全部楼层
试了下,正确
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 00:27 , Processed in 0.167652 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表