screwThreadsTest3Start.frink

Download or view screwThreadsTest3Start.frink in plain text format


/** This is a test of the screwThreads.frink library to make screw threads for
    3-d printing.  This version makes three concentric helices, also called a
    multiple-start thread.

    This test creates a male and female garden hose fitting with threads
    sort of defined by the standard ASME B1.20.8-1991 (reaffirmed 1998), but
    of course with the triple helix that makes it incompatible.
*/


use screwThreads.frink

res = 254/inch

pitch = inch/11.5
//minorRadius = 0.9495 in / 2
threadHeight = .05648 in

// Male minor radius.  This is the average of the allowed min and max pitch
// diameter (table 2) minus half the thread height.
minorRadius = (1.0060+0.9975) in /2 / 2 - threadHeight/2
turns = 4.25
pilot = 1/8 in - pitch/2

// Female major radius
//  This is the average of the allowed min and max pitch
// diameter (table 3) minus half the thread height.
femaleRadius = (1.0160 + 1.0245) in / 2 / 2 - threadHeight/2

println["threadHeight is " + format[threadHeight, "mm", 2]]
println["minorDiameter is " + format[2 minorRadius, "in", 4]]
println["majorDiameter is " + format[2 minorRadius + 2 threadHeight, "in", 4]]
println["femaleDiameter is " + format[2 femaleRadius + 2 threadHeight, "in", 4]]
println["gap is " + format[femaleRadius - minorRadius, "mm", 2]]

tool = makeDoubleConeTool[pitch/2, threadHeight, res]
maleThread1 = makeThreads[minorRadius, pitch * 3, 0, turns * 2 pi, 0 circle, tool, res]
maleThread2 = makeThreads[minorRadius, pitch * 3, 0, turns * 2 pi, 1/3 circle, tool, res]
maleThread3 = makeThreads[minorRadius, pitch * 3, 0, turns * 2 pi, 2/3 circle, tool, res]
maleThread = maleThread1.union[maleThread2].union[maleThread3]
malePipeOuter = callJava["frink.graphics.VoxelArray", "makeCylinder", [0,0,-1/4 in res,0,0,(3 turns pitch + pilot) res, minorRadius res]]
malePipeInner = callJava["frink.graphics.VoxelArray", "makeCylinder", [0,0,-1/4 in res,0,0,(3 turns pitch + pilot) res, (minorRadius-2.4 mm) res]]
male = maleThread.union[malePipeOuter]
male.remove[malePipeInner]

femaleThread1 = makeThreads[femaleRadius, pitch * 3, 0 deg, (turns+1) * 2 pi, 0 circle, tool, res]
femaleThread2 = makeThreads[femaleRadius, pitch * 3, 0 deg, (turns+1) * 2 pi, 1/3 circle, tool, res]
femaleThread3 = makeThreads[femaleRadius, pitch * 3, 0 deg, (turns+1) * 2 pi, 2/3 circle, tool, res]
femaleThread = femaleThread1.union[femaleThread2].union[femaleThread3]

femalePipeOuter = callJava["frink.graphics.VoxelArray", "makeCylinder", [0,0,-1/4 in res,0,0,(3 turns pitch) res, (femaleRadius + 2.4 mm) res]]
femalePipeInner = callJava["frink.graphics.VoxelArray", "makeCylinder", [0,0,-1/4 in res,0,0,(3 turns pitch) res, femaleRadius res]]
femalePipeOuter.remove[femalePipeInner]
femalePipeOuter.remove[femaleThread]
female = femalePipeOuter

male.projectX[undef].show["X"]
male.projectY[undef].show["Y"]
male.projectZ[undef].show["Z"]

female.projectX[undef].show["X"]
female.projectY[undef].show["Y"]
female.projectZ[undef].show["Z"]

filename = "screwThreadsMale3Start.obj"
print["Writing $filename..."]
w = new Writer[filename]
w.println[male.toObjFormat["male", 1/(res mm)]]
w.close[]
println["done."]

filename = "screwThreadsFemale3Start.obj"
print["Writing $filename..."]
w = new Writer[filename]
w.println[female.toObjFormat["female", 1/(res mm)]]
w.close[]
println["done."]


Download or view screwThreadsTest3Start.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 19966 days, 13 hours, 23 minutes ago.