明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2563|回复: 5

在VBA中,怎么用Spile画螺旋线?

[复制链接]
发表于 2003-7-28 16:17:00 | 显示全部楼层 |阅读模式
在VBA中,怎么用Spile画螺旋线?谁会知道,请赐教!
发表于 2003-7-28 20:54:00 | 显示全部楼层
发表于 2003-7-28 20:59:00 | 显示全部楼层
其实也就是通过公式计算点,然后再形成一条样条曲线罢了
 楼主| 发表于 2003-7-29 10:23:00 | 显示全部楼层
我是用公式生成点,然后手工用Spline连成圆锥螺旋线,可是用在vba中,用spline时,生成的只是一团"乱麻",不知是什么原因?而且object.AddSpline(PointsArray, StartTangent, EndTangent)中的“StartTangent, EndTangent"不知要怎么制定。请高手帮帮我。
发表于 2003-7-29 13:01:00 | 显示全部楼层
  1. Sub addsph()
  2.     Dim EentPnt As Variant
  3.     EentPnt = ThisDrawing.Utility.GetPoint(, "GetPoint")
  4.    
  5. AddHelix EentPnt, 5, 45, 10, 5
  6. End Sub
  7. Public Function AddHelix(varCentPnt As Variant, _
  8. dblRadius As Double, dblStartAng As Double, _
  9. dblPitch As Double, dblRot As Double) As AcadSpline
  10.   Dim objPoly As AcadSpline
  11.   Dim objSpace As AcadBlock
  12.   Dim objUtil As AcadUtility
  13.   Dim varSegments As Variant
  14.   Dim dblSegInclAng As Double
  15.   Dim dblSegPitch As Double
  16.   Dim dblSegAng As Double
  17.   Dim varPitchPnt As Variant
  18.   Dim intCnt As Integer
  19.   Dim dblPnts() As Double
  20.   Dim intLoopCnt As Integer
  21.   Dim intVertCnt As Integer
  22.   Dim intCoordCnt As Integer
  23.   On Error GoTo Err_Control
  24.   If ThisDrawing.ActiveSpace = acModelSpace Then
  25.     Set objSpace = ThisDrawing.ModelSpace
  26.   Else
  27.     Set objSpace = ThisDrawing.PaperSpace
  28.   End If
  29.   Set objUtil = ThisDrawing.Utility
  30.   varSegments = ThisDrawing.GetVariable("SURFTAB1")
  31.   dblSegInclAng = (2 * (Atn(1) * 4)) / varSegments
  32.   dblSegPitch = dblPitch / varSegments
  33.   dblSegAng = dblStartAng - dblSegInclAng
  34.   intLoopCnt = CInt(1 + (varSegments * dblRot))
  35.   ReDim dblPnts((intLoopCnt * 3) - 1)
  36.   For intCnt = 1 To intLoopCnt
  37.     dblSegAng = dblSegInclAng + dblSegAng
  38.     varPitchPnt = objUtil.PolarPoint(varCentPnt, _
  39.     dblSegAng, dblRadius)
  40.     varCentPnt(2) = varCentPnt(2) + dblSegPitch
  41.     For intVertCnt = 0 To 2
  42.       dblPnts(intCoordCnt) = varPitchPnt(intVertCnt)
  43.       intCoordCnt = intCoordCnt + 1
  44.     Next
  45.   Next intCnt
  46.   Dim st(2) As Double
  47.   Dim et(2) As Double
  48.   st(0) = 0: st(1) = 0: st(2) = 0
  49.   et(0) = 0: et(1) = 0: et(2) = 0
  50.   Set objPoly = objSpace.AddSpline(dblPnts, st, et)
  51.   Set AddHelix = objPoly
  52. Exit_Here:
  53.   Exit Function
  54. Err_Control:
  55.   Select Case Err.Number
  56.   'Cases here
  57.   Case Else
  58.     MsgBox Err.Description
  59.     Err.Clear
  60.     Resume Exit_Here
  61.   End Select
  62. End Function
发表于 2010-7-29 08:59:00 | 显示全部楼层

cad2007开始就有helix命令,怎么利用vba来调用这个命令来画图,实现参数化呢?谢谢回复。

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-25 23:27 , Processed in 0.183359 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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