乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 82|回复: 19

[编程交流] 管斜接脚本

[复制链接]

2

主题

14

帖子

12

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 08:10:50 | 显示全部楼层 |阅读模式
我有一个管斜接脚本,我正在尝试运行。Iv尝试加载。bas文件并运行它,但我在第2行一直遇到语法错误。。。。。。。我不知道为什么脚本不会运行,四检查了线,它似乎是正确的。如果有人能看一下。bas文件对我来说太棒了!
 
见附件。
 
谢谢你抽出时间。
 
PS:它不允许我上传。bas文件,所以我将其转换为。txt文件。
 
-AJ公司
块茎螨。txt文件
回复

使用道具 举报

2

主题

14

帖子

12

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 08:16:13 | 显示全部楼层
  1.   [font=&quot]'----------------------------------------------------------------------[/font]
  2. [font=&quot]Sub Main()[/font]
  3. [font=&quot]  Begin Dialog TUBEMITERDIALOG 50,47, 160, 96, "Tube Miter"[/font]
  4. [font=&quot]    Text         4  ,12,120,12, "Diameter of intersecting tube (mm)"[/font]
  5. [font=&quot]    TextBox      120,12,25 ,12, .IDD_D1[/font]
  6. [font=&quot]    Text         4  ,24,120,12, "Diameter of mitered tube (mm)"[/font]
  7. [font=&quot]    TextBox      120,24,25 ,12, .IDD_D2[/font]
  8. [font=&quot]    Text         4  ,36,120,12, "included angle"[/font]
  9. [font=&quot]    TextBox      120,36,25 ,12, .IDD_PHI[/font]
  10. [font=&quot]    Text         4  ,48,120,12, "Offset (mm)"[/font]
  11. [font=&quot]    TextBox      120,48,25 ,12, .IDD_OFFSET[/font]
  12. [font=&quot]    OKButton     4,80,37,12[/font]
  13. [font=&quot]    CancelButton 45,80,37,12[/font]
  14. [font=&quot]  End Dialog[/font]
  15. [font=&quot]  Dim dlg As TUBEMITERDIALOG [/font]
  16. [font=&quot]  Dim ot As Long[/font]
  17. [font=&quot]  If(dcSelectAll) Then dcEraseSelObjs[/font]
  18. [font=&quot]  dcSetDrawingScale 25.4[/font]
  19. [font=&quot]  dcSetLineParms dcBLACK, dcSOLID, dcTHIN[/font]
  20. [font=&quot]  dcSetSplineParms dcBLACK, dcSOLID, dcTHIN[/font]
  21. [font=&quot]  dlg.IDD_D1 = "25.4"[/font]
  22. [font=&quot]  dlg.IDD_D2 = "25.4"[/font]
  23. [font=&quot]  dlg.IDD_PHI = "90"[/font]
  24. [font=&quot]  dlg.IDD_OFFSET= "0.0"[/font]
  25. [font=&quot]  Button = Dialog(dlg)[/font]
  26. [font=&quot]  If Button = -1 Then[/font]
  27. [font=&quot]    Make_TubeMiter dlg.IDD_d1/2,dlg.IDD_D2/2,rad(90 - dlg.IDD_PHI),dlg.IDD_OFFSET/2[/font]
  28. [font=&quot]    dcViewAll[/font]
  29. [font=&quot]  End If[/font]
  30. [font=&quot]End Sub[/font]
  31. [font=&quot]'----------------------------------------------------------------------[/font]
  32. [font=&quot]' Square a value[/font]
  33. [font=&quot]'----------------------------------------------------------------------[/font]
  34. [font=&quot]Function square(ByVal x As Double)[/font]
  35. [font=&quot]  square = x * x [/font]
  36. [font=&quot]End Function[/font]
  37. [font=&quot]'----------------------------------------------------------------------[/font]
  38. [font=&quot]' Convert from degrees into radians[/font]
  39. [font=&quot]'----------------------------------------------------------------------[/font]
  40. [font=&quot]Function rad(ByVal deg As Double)[/font]
  41. [font=&quot]  rad = (2*3.1415926535/360)*deg[/font]
  42. [font=&quot]End Function[/font]
  43. [font=&quot]'----------------------------------------------------------------------[/font]
  44. [font=&quot]' Plot the tube miter[/font]
  45. [font=&quot]'   R1     = radius of intersecting tube[/font]
  46. [font=&quot]'   R2     = radius of intersected (cut) tube[/font]
  47. [font=&quot]'   Phi    = included angle between tubes (in radians)[/font]
  48. [font=&quot]'   Offset = offset along the z axis between the tubes[/font]
  49. [font=&quot]'[/font]
  50. [font=&quot]'[/font]
  51. [font=&quot]' The generalized equation for a cylinder of radius r about the x axis is 1 = (y/r)^2 + (z/r)^2[/font]
  52. [font=&quot]' apply the transformation y = y'cos(phi) + x'sin(phi) to rotate the cylinder about the z axis by angle phi[/font]
  53. [font=&quot]' this gives the equation 1 = ((y cos(phi) + x sin(phi))/r)^2 + (z/r)^2[/font]
  54. [font=&quot]' now solve for x to get: x = (+- r*sqrt(1-(z/r)^2) - y cos(phi))/sin(phi)[/font]
  55. [font=&quot]' we can now iterate over values of y and z to find the discreet x points that make up our curve and fit them with [/font]
  56. [font=&quot]' a spline[/font]
  57. [font=&quot]' so we'll find our y and z values by rotating around the mitered cylinder which is along the x axis.  So we get:[/font]
  58. [font=&quot]' y = R sin(alpha)[/font]
  59. [font=&quot]' z = R cos(alpha)  for alpha = 0 to 360 [/font]
  60. [font=&quot]' actually let's not forget the offset, which applies only to the Z axis, so z = R cos(alpha) + Offset[/font]
  61. [font=&quot]' we can then substitute these back into the above equation for x.[/font]
  62. [font=&quot]' This X dimension is exactly what we want to plot, but the y parmeter for plotting needs to be the circumfrence [/font]
  63. [font=&quot]' of the mitered cylinder.  so Yplot= R * alpha (if alpha is in radians) [/font]
  64. [font=&quot]' we also need to account for the fact that we support having a mitered cylinder larger than the intersecting cylinder[/font]
  65. [font=&quot]' so there is some logic there to figure out when a value is valid and not.  [/font]
  66. [font=&quot]'---------------------------------------------------------------------- [/font]
  67. [font=&quot]Sub Make_TubeMiter(ByVal R1 As Double,ByVal R2 As Double,ByVal Phi As Double,ByVal Offset As Double)[/font]
  68. [font=&quot]  Dim X As Double ' X(a)[/font]
  69. [font=&quot]  Dim s(361) As Double 'Array for the spline[/font]
  70. [font=&quot]  Dim i As Double 'i for for loop[/font]
  71. [font=&quot]  Dim start As Double 'start of a spline[/font]
  72. [font=&quot]  Dim sign As Double 'either 1 or -1 to determine the sign in the equation below[/font]
  73. [font=&quot]  Dim loopCount As Integer 'loop once if the intersecting tube is larger, twice if smaller[/font]
  74. [font=&quot]  Dim j As Integer[/font]
  75. [font=&quot]  Dim ya As Double[/font]
  76. [font=&quot]  Dim za As Double [/font]
  77. [font=&quot]  Dim alpha As Double[/font]
  78. [font=&quot]  Dim max As Double[/font]
  79. [font=&quot]  sign = -1[/font]
  80. [font=&quot]  loopCount = 1[/font]
  81. [font=&quot]  max = 0[/font]
  82. [font=&quot]  ' If the intersecting tube is smaller, we need to draw both sides[/font]
  83. [font=&quot]  ' of the intersection since it is making a hole though the tube, Thus we want to run through[/font]
  84. [font=&quot]  ' the loop twice. [/font]
  85. [font=&quot]  If (R2 + Offset > R1) Then [/font]
  86. [font=&quot]      loopCount = 2[/font]
  87. [font=&quot]  End If[/font]
  88. [font=&quot]  For j = 1 to loopCount [/font]
  89. [font=&quot]    start = -1[/font]
  90. [font=&quot]    For i=0 To 360 Step 2 'iterate 0 - 360 by 2 degree increments[/font]
  91. [font=&quot]      alpha = rad(i) 'we need everything in radians[/font]
  92. [font=&quot]      ya = R2*Sin(alpha)[/font]
  93. [font=&quot]      za = R2*Cos(alpha)+Offset[/font]
  94. [font=&quot]      'if there is something to cut here[/font]
  95. [font=&quot]      If square(za/R1) <= 1 Then[/font]
  96. [font=&quot]        X= (R1 * sign * Sqr(1 - square(za/R1)) - ya * Sin(Phi))/Cos(Phi) ' from the equation derived int he comments above[/font]
  97. [font=&quot]        ' If this is the first good sample in this spline, then record that[/font]
  98. [font=&quot]        If start = -1 Then [/font]
  99. [font=&quot]          start = i[/font]
  100. [font=&quot]        End If[/font]
  101. [font=&quot]      Else ' we are cutting a hole, and this is outside that hole[/font]
  102. [font=&quot]        X = 0.0[/font]
  103. [font=&quot]        ' this is the first sample that is outside the hole, draw the spline[/font]
  104. [font=&quot]        If start > -1 Then[/font]
  105. [font=&quot]          dcCreateSpline s(start), (i-start)/2, False[/font]
  106. [font=&quot]          start = -1[/font]
  107. [font=&quot]        End If[/font]
  108. [font=&quot]      End If[/font]
  109. [font=&quot]      ' spline point = (x,R*alpha)[/font]
  110. [font=&quot]      s(i) = X[/font]
  111. [font=&quot]      s(i+1) = R2 * alpha [/font]
  112. [font=&quot]      ' record the largest extent for the purpose of drawing reference lines[/font]
  113. [font=&quot]      If (Abs(X) > max) Then max = Abs(X)[/font]
  114. [font=&quot]    Next i[/font]
  115. [font=&quot]    ' If we stopped the loop while we still had valid values, display the spline[/font]
  116. [font=&quot]    If start > -1 Then[/font]
  117. [font=&quot]      dcCreateSpline s(start), (362 - start)/2, False[/font]
  118. [font=&quot]    End If[/font]
  119. [font=&quot]    ' swap the sign just in case we need to run through the loop again[/font]
  120. [font=&quot]    sign = 1[/font]
  121. [font=&quot]  Next j[/font]
  122. [font=&quot]  ' Draw reference lines[/font]
  123. [font=&quot]  dcCreateLine  (-2*max), (R2 * rad(0)  ), (2*max), (R2 * rad(0)  )[/font]
  124. [font=&quot]  dcCreateLine  (-2*max), (R2 * rad(90) ), (2*max), (R2 * rad(90) )[/font]
  125. [font=&quot]  dcCreateLine  (-2*max), (R2 * rad(180)), (2*max), (R2 * rad(180))[/font]
  126. [font=&quot]  dcCreateLine  (-2*max), (R2 * rad(270)), (2*max), (R2 * rad(270))[/font]
  127. [font=&quot]  dcCreateLine  (-2*max), (R2 * rad(360)), (2*max), (R2 * rad(360))[/font]
  128. [font=&quot]End Sub[/font]
回复

使用道具 举报

10

主题

973

帖子

909

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 08:17:35 | 显示全部楼层
本模块中没有几个支持元素。没有这些元素,就没有简单的方法来测试和提供建议。
 
此例程的目的是创建未包装的斜接,如本线程中所述:
 
http://www.cadtutor.net/forum/showthread.php?t=29251
回复

使用道具 举报

2

主题

14

帖子

12

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 08:22:28 | 显示全部楼层
 
是的,关于展开模板,您是正确的,但在该线程中讨论的是直线切割。我想最好的名字应该是Tube Cope?如果您查看该线程并从PAULMCZ下载名为“pipe fitting lsp.dwg”的dwg。你会看到一个标签为“TJ计划”,这更像是我想要做的。我不想要在管子上直接切割,我想要一个顶盖,这样一个相交的管子会平稳地铺在另一个管子上,以便进行良好的焊接。
 

                               
登录/注册后可看大图


                               
登录/注册后可看大图

示例。。。。
 
谢谢你的回复。
 
-AJ公司
回复

使用道具 举报

10

主题

973

帖子

909

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 08:24:32 | 显示全部楼层
我看这会有什么帮助。但是,正如我所说,您发布的模块(.bas)不完整。有些函数dcCreateLine和dcCreateSpline不存在。如果你有权访问它们,请将其张贴出来,以便提供更明智的建议。没有它们,这将是一个相当激烈的逆向工程项目。
 
这个主题很有趣,我不介意在空闲的时候研究它(可能是作为一个C项目)。
 
在平均时间后#13http://www.cadtutor.net/forum/showthread.php?t=29251包含一个链接,指向一个可能符合要求的独立程序。
回复

使用道具 举报

2

主题

14

帖子

12

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 08:27:11 | 显示全部楼层
 
是的,我已经有一些程序可以为我做,但它们都只是直接打印。我想在CAD中做点什么,这样我就可以使用线条添加额外的尺寸。BAS文件是为“DeltaCAD”制作的,它在那里工作,只是在AutoCAD中不工作。。。
 
我不擅长数学,但它就像你用excel文件处理斜接坐标一样,可以用同样的方法处理。我确实知道完成手术需要什么公式。你想让我帮你贴出完整的等式。这是一个链接到完整的方程式。我想它会将该方程求解180次(每2度)以完成展开模板。
 
http://metalgeek.com/static/dan/derivation.html
 
-AJ公司
回复

使用道具 举报

10

主题

973

帖子

909

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 08:32:25 | 显示全部楼层
是否可以安全地假设打印的曲线将作为管外径的参考,但关键几何形状是内径?我还假设初始切割将通过跳汰锯进行,锯片保持与管表面垂直的方向。
 
在你上一篇文章中链接的照片显示了切割地面背面的外部部分(以允许良好的焊缝),只有用于索引适当角度的内部边缘。
 
编辑:实际上,经过进一步思考,我可以看到用带锯切割管子会如何改变参数。
回复

使用道具 举报

26

主题

1495

帖子

20

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 08:35:42 | 显示全部楼层
我过去在钻床上使用的是一种金属切割孔锯(与要相交的管子直径相同),通过夹具将管子固定在适当的角度。钻一个导向孔,然后去钻。
 
为了进行生产工作,他们制作了一种工具和模具,该工具和模具可以一次装入冲床和切口的一侧。还有激光切割-大卫
091106d7gvjlgj4guxupx4.jpg
回复

使用道具 举报

2

主题

14

帖子

12

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 08:39:01 | 显示全部楼层
 
是的,你所说的一切都是正确的。我通常会磨掉外缘,这样就不必在很薄的金属上焊接了。焊接时它给了我更多的肉,这产生了一个漂亮的焊缝。我给你们发的那些管子的图片,是用一个像有人从下面开始锯的孔,用一个磨机实际切割的地方。
 
我会在所有的切口上使用孔锯,但在做不同角度的切割时,很难把东西排好。直尺在铣床上很容易,但我只是没有夹具的设备来固定它在不同的角度。
 
-AJ公司
回复

使用道具 举报

2

主题

14

帖子

12

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 08:42:27 | 显示全部楼层
 
这也是我在做管子斜接时通常使用的过程,但正如我在上面对肖特说的那样,我没有合适的虎钳来固定夹具,以使管子保持复合角度。您还提到了一个冲床的管槽口。我们的商店里也有这个,它是为钢铁工人设计的凹口,但它只有90度(直管)的凹口,就像我拍的那些。
 
这些展开模板是最快速、最简单的操作。我可以用手带做一个基本的90度缺口,比我去磨坊用孔锯切割要快。展开后会给我基本的线条和切割位置,使我达到大致的形状,然后我使用研磨机进行平滑处理,以获得合适的精加工配件
 
-AJ。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-9 09:38 , Processed in 0.449898 second(s), 74 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表