What's new

TUTORIAL: TUBEFIT Algorithm

ajayre

Alibre Super User
A recent posting about Thein Separators mentioned Dan Hopper's TUBEFIT algorithm. Details can be found here:

http://metalgeek.com/static/dan/derivation.html

What follows is an example of how to implement this using WizoScript (http://www.wizotools.com). I hope it serves as a demonstration of how algorithms can be applied to Geomagic Design.

First step is to make sure the python math library is avaiable. We do that with:

Code:
import math
from math import *

Now we define the parameters:

Code:
# uncut tube radius
RU = 30
# cut tube inside radius
RI = 20
# cut tube outside radius
RO = 22
# cut tube length
Length = 150
# angle of intersecton of tubes
AF = 70

Next step is to create the tube. We do that by creating a new part, adding a 2D sketch that contains a circle, extruding, adding another circle for the inside and extrude cutting:

Code:
P = Part("Cut Tube")
Profile = P.AddSketch("Profile", P.GetPlane("XY-Plane"))
Profile.AddCircle(0, 0, RO*2, False)
CutTube = P.AddExtrudeBoss("Tube", Profile, Length, False)
InsideProfile = P.AddSketch("Inside Profile", P.GetPlane("XY-Plane"))
InsideProfile.AddCircle(0, 0, RI*2, False)
Hole = P.AddExtrudeCut("Hole", InsideProfile, Length, False)

The python math library, like most (all?) computation libraries uses radians rather than degrees, so now we need to convert the intersection angle to radians:

Code:
# convert to radians
AF = AF * pi / 180

Now we use the TUBEFIT algorithm to calculate a set of 3D points. On Dan Hopper's page he runs the calculation 180 times (every two degrees), so we will do the same:

Code:
Points = []
for ODdeg in xrange(0, 360, 2):
  OD = ODdeg * pi / 180
  YO = sqrt(RU**2 - RI**2 + (RO * cos(OD))**2) / sin(AF) - tan(90 - AF) * RO * cos(OD)
  X = cos(OD) * RO
  Y = sin(OD) * RO
  Points.extend([X, Y, YO])

The result of this chunk of code is that we have an array called Points with a set of coordinates. It has the form:

[X1, Y1, Z1, X2, Y2, Z2, ..., Xn, Yn, Zn]

We need to make sure the curve is closed. That is easily achieved by making sure the last point is the same as the first point. We can do that with:

Code:
# close curve
Points.extend([Points[0], Points[1], Points[2]])

Finally we can plot the 3D curve on the tube for later analysis:

Code:
CutPath = P.Add3DSketch("Cut Path")
CutPath.AddBspline(Points)
 

Attachments

  • tubefit-1.png
    tubefit-1.png
    14.3 KB · Views: 559
  • tubefit-2.png
    tubefit-2.png
    32.8 KB · Views: 17
  • tubefit-3.png
    tubefit-3.png
    30.6 KB · Views: 559
Top