找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 733|回复: 0

[求助]:VBA中,按路径拉伸的问题。

[复制链接]
发表于 2005-6-11 19:37:18 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

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

×
上面的代码运行到Set solidObj = ThisDrawing.ModelSpace.AddExtrudedSolidAlongPath(circleObj(0), polyObj)时出错,可以画出用来拉伸的的圆和拉伸的路径。其实我也知道上面的代码会有些错误,因为我删掉了一些我看不懂的代码。我想请教一下大家,把上面的代码补完整。谢谢啦!

  1.   [FONT=courier new]
  2. Sub Example_AddExtrudedSolidAlongPath()
  3.      di = Val(TextBox4.Text)
  4.      d0 = Val(TextBox5.Text)
  5.      W = Val(TextBox6.Text)
  6.      D = Val(TextBox7.Text)
  7.      H = Val(TextBox8.Text)
  8.      N = Val(TextBox9.Text)
  9.      L = Val(TextBox10.Text)
  10.      I = Val(TextBox11.Text)
  11.     ' This example extrudes a solid from a region
  12.     ' along a path defined by a spline.
  13.     ' The region is created from an arc and a line.
  14.    
  15.    
  16.    
  17.      ' This example creates a circle in model space.
  18.     Dim circleObj As AcadCircle
  19.     Dim centerPoint(0 To 2) As Double
  20.     Dim radius As Double
  21.    
  22.     ' Define the circle
  23.     centerPoint(0) = 500 * W - 1200 * D / (N + 1): centerPoint(1) = 500 * H + 500 * d0: centerPoint(2) = 500 * D - 1000 * D / (N + 1)
  24.     radius = 500 * d0
  25.    
  26.     ' Create the Circle object in model space
  27.     Set circleObj = ThisDrawing.ModelSpace.AddCircle(centerPoint, radius)

  28.     ' Define the rotation axis with two points
  29.     Dim rotatePt1(0 To 2) As Double
  30.     Dim rotatePt2(0 To 2) As Double
  31.     Dim rotateAngle As Double
  32.    
  33.     rotatePt1(0) = 500 * W - 1200 * D / (N + 1): rotatePt1(1) = 500 * H + 500 * d0: rotatePt1(2) = 500 * D - 1000 * D / (N + 1)
  34.     rotatePt2(0) = 500 * W - 1200 * D / (N + 1): rotatePt2(1) = 0: rotatePt2(2) = 500 * D - 1000 * D / (N + 1)
  35.     rotateAngle = 90
  36.     rotateAngle = rotateAngle * 3.141592 / 180
  37.    
  38.       
  39.     ' Rotate the Circle
  40.     circleObj.Rotate3D rotatePt1, rotatePt2, rotateAngle
  41.    
  42.    
  43.     ' Define the extrusion path (3DPolyline object)
  44.      Dim polyObj As Acad3DPolyline
  45.      Dim points(0 To 14) As Double

  46.     ' Define the 3D polyline points
  47.     points(0) = 500 * W - 1200 * D / (N + 1): points(1) = 500 * H + 500 * d0: points(2) = 500 * D - 1000 * D / (N + 1)
  48.     points(3) = -500 * W - 500 * d0: points(4) = 500 * H + 500 * d0: points(5) = 500 * D - 1000 * D / (N + 1)
  49.     points(6) = -500 * W - 500 * d0: points(7) = -500 * H - 500 * d0: points(8) = 500 * D - 1000 * D / (N + 1)
  50.     points(9) = 500 * W + 500 * d0: points(10) = -500 * H - 500 * d0: points(11) = 500 * D - 1000 * D / (N + 1)
  51.     points(12) = 500 * W + 500 * d0: points(13) = 500 * H - 1200 * D / (N + 1): points(14) = 500 * D - 1000 * D / (N + 1)
  52.    
  53.     ' Create a 3DPolyline in model space
  54.     Set polyObj = ThisDrawing.ModelSpace.Add3DPoly(points)
  55.     ' Create the solid
  56.    
  57.     Dim solidObj As Acad3DSolid
  58.     Set solidObj = ThisDrawing.ModelSpace.AddExtrudedSolidAlongPath(circleObj(0), polyObj)
  59.     ZoomAll
  60.    
  61. End Sub
  62.   [/FONT]


注:绘图时参考数据
蒸发器冷却排管围数:4
蒸发管外径:0.0065
冷冻室宽度:0.421
冷冻室深度:0.411
冷冻室高度:0.314
其他不用填
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-9-21 13:50 , Processed in 0.173198 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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