找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 722|回复: 2

[求助]:VBA中拉伸的问题。修改以前的贴子,节约论坛资源。6.11

[复制链接]
发表于 2005-6-3 00:49:33 | 显示全部楼层 |阅读模式

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

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

×
为了节约论坛资源,我修改以前的贴子。

  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]


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

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

使用道具 举报

 楼主| 发表于 2005-6-3 11:39:59 | 显示全部楼层
我把里面看不懂的代码加进去。程序运行到Set curves(1) = ThisDrawing.ModelSpace.AddLine(curves(0).StartPoint, curves(0).EndPoint)
时停止。这些代码应该如何改呢?谢谢啦!

  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.      Dim curves(0 To 1) As AcadEntity
  43.      
  44.      Set curves(0) = ThisDrawing.ModelSpace.AddCircle(centerPoint, radius)
  45.      Set curves(1) = ThisDrawing.ModelSpace.AddLine(curves(0).StartPoint, curves(0).EndPoint)
  46.      
  47.      ' Create the region
  48.      Dim regionObj As Variant
  49.      regionObj = ThisDrawing.ModelSpace.AddRegion(curves)
  50.    


  51.    
  52.     ' Define the extrusion path (3DPolyline object)
  53.      Dim polyObj As Acad3DPolyline
  54.      Dim points(0 To 14) As Double

  55.     ' Define the 3D polyline points
  56.     points(0) = 500 * W - 1200 * D / (N + 1): points(1) = 500 * H + 500 * d0: points(2) = 500 * D - 1000 * D / (N + 1)
  57.     points(3) = -500 * W - 500 * d0: points(4) = 500 * H + 500 * d0: points(5) = 500 * D - 1000 * D / (N + 1)
  58.     points(6) = -500 * W - 500 * d0: points(7) = -500 * H - 500 * d0: points(8) = 500 * D - 1000 * D / (N + 1)
  59.     points(9) = 500 * W + 500 * d0: points(10) = -500 * H - 500 * d0: points(11) = 500 * D - 1000 * D / (N + 1)
  60.     points(12) = 500 * W + 500 * d0: points(13) = 500 * H - 1200 * D / (N + 1): points(14) = 500 * D - 1000 * D / (N + 1)
  61.    
  62.     ' Create a 3DPolyline in model space
  63.     Set polyObj = ThisDrawing.ModelSpace.Add3DPoly(points)
  64.     ' Create the solid
  65.    
  66.     Dim solidObj As Acad3DSolid
  67.     Set solidObj = ThisDrawing.ModelSpace.AddExtrudedSolidAlongPath(regionObj(0), polyObj)
  68.     ZoomAll
  69.    
  70. End Sub
  71.   [/FONT]
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-27 07:08 , Processed in 0.219906 second(s), 36 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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