From 0233c75e89ac5d7d909450fd9466c5138ac5f228 Mon Sep 17 00:00:00 2001 From: Adrian Schlatter Date: Sat, 6 Apr 2019 18:29:25 +0200 Subject: [PATCH] Create thread by designator +++++++++++++++++++++++++++ Created generalized thread-module that creates a thread by looking up the designator in THREAD_TABLE. --- BSPthread.scad | 71 +++++++++++++------------------------- BSPthread/autogenerate.awk | 4 +++ THREAD_TABLE.scad | 51 +++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 47 deletions(-) create mode 100644 BSPthread/autogenerate.awk create mode 100644 THREAD_TABLE.scad diff --git a/BSPthread.scad b/BSPthread.scad index dc6f05e..cdb0ed7 100644 --- a/BSPthread.scad +++ b/BSPthread.scad @@ -28,72 +28,49 @@ in practice! */ use +include +function thread_specs(designator) = + /* Returns thread specs of thread-type 'designator' as a vector of + [pitch, Rrotation, Dsupport, section_profile] */ + + THREAD_TABLE[search([designator], THREAD_TABLE, num_returns_per_match=1, + index_col_num=0)[0]][1]; -module BSPP_external_thread(pitch=2.309, turns=3, dpitch=31.68, higbee_arc=45, fn=120) +module thread(designator, turns, higbee_arc=45, fn=120) { - rpitchp = dpitch / 2; - P = pitch; - - rcrest = rpitchp + 0.21706 * P; - rvalley = rpitchp - 0.42021 * P; - zvalley = 0.03125 * P; - zcrest = 0.13701 * P; - - section_profile = [[rvalley, -P / 2 + zvalley], [rvalley, +P / 2 - zvalley], - [rcrest, +zcrest], - [rcrest, -zcrest]]; - + specs = thread_specs(designator); + P = specs[0]; Rrotation = specs[1]; section_profile = specs[3]; + echo(designator, "Rrotation", Rrotation); straight_thread( section_profile=section_profile, higbee_arc=higbee_arc, - r=0, + r=Rrotation, turns=turns, - pitch=pitch, - fn=fn); + pitch=P); } -module BSPP_internal_thread(pitch=2.309, turns=3, dpitch=31.86, higbee_arc=45, fn=120) -{ - rpitchp = dpitch / 2; - P = pitch; - - rcrest = rpitchp - 0.19813 * P; - rvalley = rpitchp + 0.42021 * P; - zvalley = 0.03125 * P; - zcrest = 0.13701 * P; - - section_profile = [[rvalley, P / 2 - zvalley], [rvalley, -P / 2 + zvalley], - [rcrest, -zcrest], [rcrest, +zcrest]]; - - rotate(180) // rotate by half a turn to fit external thread - straight_thread( - section_profile=section_profile, - higbee_arc=higbee_arc, - r=0, - turns=turns, - pitch=pitch, - fn=fn); -} // testing: +type = "G1"; intersection() { color("Green") - translate([-50, 0, -50]) - cube(100, 100, 100); + translate([-100, 0, -100]) + cube(200, 200, 200); union() { - BSPP_external_thread(pitch=2.309, turns=3, dpitch=31.68, - higbee_arc=20, fn=120); + echo("Dsupport", thread_specs(str(type, "-ext"))[2]); + thread(str(type, "-ext"), turns=3, higbee_arc=20, fn=120); translate([0, 0, -1.2]) - cylinder(h=9, r=31.68/2 - 0.40020 * 2.309); - BSPP_internal_thread(pitch=2.309, turns=3, dpitch=31.86, - higbee_arc=20, fn=120); + cylinder(h=9, d=thread_specs(str(type, "-ext"))[2], $fn=120); + + rotate(180) + thread(str(type, "-int"), turns=3, higbee_arc=20, fn=120); translate([0, 0, -0.9]) difference() { - cylinder(h=9, r=20, $fn=120); + cylinder(h=9, r=200, $fn=120); translate([0, 0, -0.1]) - cylinder(h=10, r=31.86/2 + 0.40020 * 2.309, $fn=120); + cylinder(h=10, d=thread_specs(str(type, "-int"))[2], $fn=120); }; }; }; diff --git a/BSPthread/autogenerate.awk b/BSPthread/autogenerate.awk new file mode 100644 index 0000000..b202159 --- /dev/null +++ b/BSPthread/autogenerate.awk @@ -0,0 +1,4 @@ +BEGIN { print "/* This script is auto-generated - do not edit */" + printf "\nTHREAD_TABLE = [" } +/^G/ { print "[\"" $1 "\", [" $2 ", " $3 ", " $4 ", [[" $5 ", " $6 "], [" $7 ", " $8 "], [" $9 ", " $10 "], [" $11 ", " $12 "]]]],"} +END { print "];" } diff --git a/THREAD_TABLE.scad b/THREAD_TABLE.scad new file mode 100644 index 0000000..d2b284b --- /dev/null +++ b/THREAD_TABLE.scad @@ -0,0 +1,51 @@ +/* This script is auto-generated - do not edit */ + +THREAD_TABLE = [["G1/16-int", [0.907, 3.97888486, 7.921471162, [[0, 0.42515625], [0, -0.42515625], [-0.560841406, -0.12426807], [-0.560841406, 0.12426807]]]], +["G1/8-int", [0.907, 4.98138486, 9.926471162, [[0, 0.42515625], [0, -0.42515625], [-0.560841406, -0.12426807], [-0.560841406, 0.12426807]]]], +["G1/4-int", [1.337, 6.743577241, 13.43364713, [[0, 0.62671875], [0, -0.62671875], [-0.826730937, -0.18318237], [-0.826730937, 0.18318237]]]], +["G3/8-int", [1.337, 8.496077241, 16.93864713, [[0, 0.62671875], [0, -0.62671875], [-0.826730937, -0.18318237], [-0.826730937, 0.18318237]]]], +["G1/2-int", [1.814, 10.69426972, 21.31594232, [[0, 0.8503125], [0, -0.8503125], [-1.121682812, -0.24853614], [-1.121682812, 0.24853614]]]], +["G5/8-int", [1.814, 11.67226972, 23.27194232, [[0, 0.8503125], [0, -0.8503125], [-1.121682812, -0.24853614], [-1.121682812, 0.24853614]]]], +["G3/4-int", [1.814, 13.43726972, 26.80194232, [[0, 0.8503125], [0, -0.8503125], [-1.121682812, -0.24853614], [-1.121682812, 0.24853614]]]], +["G7/8-int", [1.814, 15.31726972, 30.56194232, [[0, 0.8503125], [0, -0.8503125], [-1.121682812, -0.24853614], [-1.121682812, 0.24853614]]]], +["G1-int", [2.309, 16.90027607, 33.70814489, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609]]]], +["G1 1/8-int", [2.309, 19.22427607, 38.35614489, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609]]]], +["G1 1/4-int", [2.309, 21.23077607, 42.36914489, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609]]]], +["G1 1/2-int", [2.309, 24.17727607, 48.26214489, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609]]]], +["G1 3/4-int", [2.309, 27.14877607, 54.20514489, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609]]]], +["G2-int", [2.309, 30.08277607, 60.07314489, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609]]]], +["G2 1/4-int", [2.309, 33.14002607, 66.18764489, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609]]]], +["G2 1/2-int", [2.309, 37.87702607, 75.66164489, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609]]]], +["G2 3/4-int", [2.309, 41.05202607, 82.01164489, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609]]]], +["G3-int", [2.309, 44.22702607, 88.36164489, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609]]]], +["G3 1/2-int", [2.309, 50.45002607, 100.8076449, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609]]]], +["G4-int", [2.309, 56.80002607, 113.5076449, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609]]]], +["G4 1/2-int", [2.309, 63.15002607, 126.2076449, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609]]]], +["G5-int", [2.309, 69.50002607, 138.9076449, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609]]]], +["G5 1/2-int", [2.309, 75.85002607, 151.6076449, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609]]]], +["G6-int", [2.309, 82.20002607, 164.3076449, [[0, 1.08234375], [0, -1.08234375], [-1.427764947, -0.31635609], [-1.427764947, 0.31635609]]]], +["G1/16-ext", [0.907, 3.21661514, 6.469528838, [[0, -0.42515625], [0, 0.42515625], [0.578008291, 0.12426807], [0.578008291, -0.12426807]]]], +["G1/8-ext", [0.907, 4.21911514, 8.474528838, [[0, -0.42515625], [0, 0.42515625], [0.578008291, 0.12426807], [0.578008291, -0.12426807]]]], +["G1/4-ext", [1.337, 5.619922759, 11.29335287, [[0, -0.62671875], [0, 0.62671875], [0.852036477, 0.18318237], [0.852036477, -0.18318237]]]], +["G3/8-ext", [1.337, 7.372422759, 14.79835287, [[0, -0.62671875], [0, 0.62671875], [0.852036477, 0.18318237], [0.852036477, -0.18318237]]]], +["G1/2-ext", [1.814, 9.16973028, 18.41205768, [[0, -0.8503125], [0, 0.8503125], [1.156016582, 0.24853614], [1.156016582, -0.24853614]]]], +["G5/8-ext", [1.814, 10.14773028, 20.36805768, [[0, -0.8503125], [0, 0.8503125], [1.156016582, 0.24853614], [1.156016582, -0.24853614]]]], +["G3/4-ext", [1.814, 11.91273028, 23.89805768, [[0, -0.8503125], [0, 0.8503125], [1.156016582, 0.24853614], [1.156016582, -0.24853614]]]], +["G7/8-ext", [1.814, 13.79273028, 27.65805768, [[0, -0.8503125], [0, 0.8503125], [1.156016582, 0.24853614], [1.156016582, -0.24853614]]]], +["G1-ext", [2.309, 14.95972393, 30.01185511, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609]]]], +["G1 1/8-ext", [2.309, 17.28372393, 34.65985511, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609]]]], +["G1 1/4-ext", [2.309, 19.29022393, 38.67285511, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609]]]], +["G1 1/2-ext", [2.309, 22.23672393, 44.56585511, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609]]]], +["G1 3/4-ext", [2.309, 25.20822393, 50.50885511, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609]]]], +["G2-ext", [2.309, 28.14222393, 56.37685511, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609]]]], +["G2 1/4-ext", [2.309, 31.19947393, 62.49135511, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609]]]], +["G2 1/2-ext", [2.309, 35.93647393, 71.96535511, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609]]]], +["G2 3/4-ext", [2.309, 39.11147393, 78.31535511, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609]]]], +["G3-ext", [2.309, 42.28647393, 84.66535511, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609]]]], +["G3 1/2-ext", [2.309, 48.50947393, 97.11135511, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609]]]], +["G4-ext", [2.309, 54.85947393, 109.8113551, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609]]]], +["G4 1/2-ext", [2.309, 61.20947393, 122.5113551, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609]]]], +["G5-ext", [2.309, 67.55947393, 135.2113551, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609]]]], +["G5 1/2-ext", [2.309, 73.90947393, 147.9113551, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609]]]], +["G6-ext", [2.309, 80.25947393, 160.6113551, [[0, -1.08234375], [0, 1.08234375], [1.471467634, 0.31635609], [1.471467634, -0.31635609]]]], +];