|
1 // Threading.scad - library for threadings |
|
2 // Autor: Rudolf Huttary, Berlin 2016 |
|
3 |
|
4 use <Naca_sweep.scad> // http://www.thingiverse.com/thing:900137 |
|
5 |
|
6 // examples |
|
7 showexample = 10; // choose your example number |
|
8 |
|
9 example(showexample) |
|
10 { |
|
11 // #1 ACME thread |
|
12 threading(pitch = 2, d=20, windings = 5, angle = 29); |
|
13 |
|
14 // #2 threaded rod 20° |
|
15 threading(pitch = 2, d=20, windings = 30, angle = 20, full = true); |
|
16 |
|
17 // #3 nut for threaded rod 20° |
|
18 Threading(pitch = 2, d=20, windings = 10, angle = 20, full = true); |
|
19 |
|
20 // #4 nut for threaded rod 20°, own diameter 25 mm, hires |
|
21 Threading(D = 25, pitch = 2, d=20, windings = 10, angle = 20, full = true, step = 50, $fn=100); |
|
22 |
|
23 // #5 triple helix threaded rod |
|
24 threading(pitch = 2, d=20, windings = 30, helices = 3, angle = 20, full = true); |
|
25 |
|
26 // #6 toothed rod (no pitch) |
|
27 threading(helices = 0, angle = 20, full = true); |
|
28 |
|
29 // #7 toothed cube (no pitch) |
|
30 threading(helices = 0, angle = 60, full = true, steps=4); |
|
31 |
|
32 // #8 M8 hex bolt |
|
33 union(){ |
|
34 threading(pitch = 1.25, d=8, windings=20, full=true); cylinder(d=14.6, h=4, $fn=6);} |
|
35 // #9 M8 hex nut |
|
36 Threading(D=14.6, pitch = 1.25, d=8, windings=5, full=true, $fn=6); |
|
37 // #10 M8 four socket nut |
|
38 Threading(D=16, pitch = 1.25, d=8, windings=5, full=true, $fn=4); |
|
39 } |
|
40 |
|
41 module example(number=0) if(number) children(number-1); |
|
42 |
|
43 help(); |
|
44 module help() |
|
45 { |
|
46 helpstr = |
|
47 "Thread library - Rudolf Huttary \n |
|
48 D = {0=auto}; // Cyl diameter Threading() \n |
|
49 d = 6; // outer diameter thread() \n |
|
50 windings = 10; // number of windings \n |
|
51 helices = 1; // number of threads \n |
|
52 angle = 60; // open angle <76, bolts: 60°, ACME: 29°, toothed Racks: 20° \n |
|
53 steps = 40; // resolution \n |
|
54 help(); // show help in console |
|
55 threading(pitch = 1, d = 6, windings = 10, helices = 1, angle = 60, steps=40, full = false) \n |
|
56 Threading(D = 0, pitch = 1, r = 6, windings = 10, helices = 1, angle = 60, steps=40) \n |
|
57 "; |
|
58 echo (helpstr); |
|
59 } |
|
60 |
|
61 //Threading(R=12, pitch = pitch, r=radius, windings= windings, angle = angle); |
|
62 |
|
63 module Threading(D = 0, pitch = 1, d = 12, windings = 10, helices = 1, angle = 60, steps=40) |
|
64 { |
|
65 R = D==0?d/2+2*pitch/PI:D/2; |
|
66 translate([0,0,-pitch]) |
|
67 difference() |
|
68 { |
|
69 translate([0,0,pitch]) |
|
70 cylinder (r=R, h =pitch*(windings-helices)); |
|
71 threading(pitch, d, windings, helices, angle, steps, true); |
|
72 } |
|
73 } |
|
74 |
|
75 module threading(pitch = 1, d = 12, windings = 10, helices = 1, angle = 60, steps=40, full = false) |
|
76 { // tricky: glue two 180° pieces together to get a proper manifold |
|
77 r = d/2; |
|
78 Steps = steps/2; |
|
79 Pitch = pitch*helices; |
|
80 if(full) cylinder(r = r-.5-pitch/PI, h=pitch*(windings+helices), $fn=steps); |
|
81 sweep(gen_dat()); // half screw |
|
82 rotate([0, 0, 180]) translate([0, 0, Pitch/2]) |
|
83 sweep(gen_dat()); // half screw |
|
84 echo(steps); |
|
85 function gen_dat() = let(ang = 180, bar = R_(180, -90, 0, Ty_(-r+.5, vec3D(pitch/PI*Rack(windings, angle))))) |
|
86 [for (i=[0:Steps]) Tz_(i/2/Steps*Pitch, Rz_(i*ang/Steps, bar))]; |
|
87 |
|
88 function Rack(w, angle) = |
|
89 concat([[0, 2]], [for (i=[0:windings-1], j=[0:3]) |
|
90 let(t = [ [0, 1], [2*tan(angle/2), -1], [PI/2, -1], [2*tan(angle/2)+PI/2, 1]]) |
|
91 [t[j][0]+i*PI, t[j][1]]], [[w*PI, 1], [w*PI, 2]]); |
|
92 } |
|
93 |