Commit | Line | Data |
---|---|---|
28ef71df CE |
1 | // Threads for acorn model |
2 | // Copyright (c) 2017 Clinton Ebadi <clinton@unknownlamer.org> | |
3 | ||
0cbf5490 | 4 | use <screw_threads.scad> // http://www.thingiverse.com/thing:1686322 |
28ef71df | 5 | |
244fc8f0 | 6 | AUTO_CALCULATE = -1; |
28ef71df | 7 | |
5d6b539a CE |
8 | acorn_parts = [ "body", "cap", "gasket" ]; |
9 | ||
0cbf5490 CE |
10 | internal_thread_tolerance = 0.3; |
11 | external_thread_tolerance = 0.2; | |
12 | thread_angle = 50; | |
28ef71df | 13 | |
5d6b539a CE |
14 | |
15 | function contains (x, lst) = len([ for (i = lst) if (x == i) i]) > 0; | |
16 | ||
b097fbc1 CE |
17 | // dome module from https://github.com/Sembiance/common/blob/master/openscad/dome.scad, Public Domain |
18 | module dome(d=5, h=2, hollow=false, wallWidth=0.5) { | |
19 | sphereRadius = (pow(h, 2) + pow((d/2), 2) ) / (2*h); | |
20 | translate([0, 0, (sphereRadius-h)*-1]) { | |
21 | difference() { | |
22 | sphere(sphereRadius); | |
23 | translate([0, 0, -h]) cube([2*sphereRadius, 2*sphereRadius, 2*sphereRadius], center=true); | |
24 | if(hollow) sphere(sphereRadius-wallWidth); | |
25 | } | |
26 | } | |
27 | } | |
28 | ||
244fc8f0 CE |
29 | module acorn (thread_pitch = 3.0, |
30 | thread_size = 2.5, | |
31 | thread_height = 3.5, | |
32 | thread_tooth_height = AUTO_CALCULATE, | |
28ef71df | 33 | |
244fc8f0 CE |
34 | inner_d = 24.5, |
35 | base_height = AUTO_CALCULATE, | |
36 | wall_thickness = AUTO_CALCULATE, | |
37 | outer_d = AUTO_CALCULATE, | |
1b73bd8e | 38 | dome_h = AUTO_CALCULATE, |
28ef71df | 39 | |
244fc8f0 CE |
40 | keychain = true) { |
41 | ||
42 | // derived settings | |
43 | wall_thickness = (wall_thickness == AUTO_CALCULATE) ? thread_size : wall_thickness; | |
44 | outer_d = (outer_d == AUTO_CALCULATE) ? inner_d + wall_thickness*2 : outer_d; | |
45 | thread_tooth_height = (thread_tooth_height == AUTO_CALCULATE) ? ((thread_pitch - 0.4 > 0) ? thread_pitch - 0.4 : thread_pitch) : thread_tooth_height; | |
46 | base_height = (base_height == AUTO_CALCULATE) ? inner_d : base_height; | |
47 | ||
b097fbc1 CE |
48 | echo ("outer_d = ", outer_d); |
49 | ||
244fc8f0 CE |
50 | |
51 | module acorn_thread (outer_d = outer_d, internal = false, ring = true) { | |
52 | if (internal) { | |
53 | outer_ring_d = outer_d+max(thread_size, wall_thickness)+1; | |
54 | echo ("outer ring = ", outer_ring_d); | |
55 | ScrewHole (outer_diam=outer_d, height = thread_height, pitch = thread_pitch, tooth_height = thread_tooth_height, tooth_angle = thread_angle, tolerance=internal_thread_tolerance) { | |
56 | if (ring) cylinder (d = outer_ring_d, h = thread_height); | |
57 | } | |
28ef71df | 58 | } |
28ef71df | 59 | |
244fc8f0 CE |
60 | if (!internal) { |
61 | difference () { | |
62 | ScrewThread (outer_diam=outer_d, height = thread_height, pitch = thread_pitch, tooth_height = thread_tooth_height, tooth_angle = thread_angle, tolerance=external_thread_tolerance); | |
63 | cylinder (d = outer_d-wall_thickness-thread_size-0.01, h = thread_height * 4, center=true); | |
64 | } | |
28ef71df CE |
65 | } |
66 | } | |
28ef71df | 67 | |
244fc8f0 CE |
68 | module nut_body (h = base_height, d = outer_d, nub = false) { |
69 | translate ([0 ,0, h]) { | |
70 | intersection () { | |
71 | union () { | |
72 | resize ([d, d, h*2]) sphere (d=h*2); | |
73 | if (nub) { | |
74 | translate ([0, d/2-wall_thickness/2, -thread_height]) sphere (d=wall_thickness*2, $fs = 0.1); | |
75 | } | |
0cbf5490 | 76 | } |
244fc8f0 | 77 | translate ([0 ,0, -h/2]) cube ([d*2, d*2, h], center=true); |
0cbf5490 | 78 | } |
0cbf5490 | 79 | } |
28ef71df | 80 | } |
28ef71df | 81 | |
244fc8f0 CE |
82 | module nut () { |
83 | difference () { | |
84 | nut_body (); | |
85 | translate ([0, 0, wall_thickness + 0.01]) nut_body (d=outer_d-wall_thickness*2, nub=false); | |
86 | } | |
28ef71df | 87 | |
244fc8f0 CE |
88 | translate ([0, 0, base_height-0.1]) acorn_thread (outer_d = outer_d); |
89 | } | |
28ef71df | 90 | |
28ef71df | 91 | |
b097fbc1 | 92 | module cap_keychain_holes (hole_d=3, spacing=12) { |
244fc8f0 CE |
93 | h=100; |
94 | translate ([-spacing/2, 0, 0]) cylinder (d=hole_d, h=h, $fs=0.1); | |
95 | translate ([spacing/2, 0, 0]) cylinder (d=hole_d, h=h, $fs=0.1); | |
96 | } | |
28ef71df | 97 | |
b097fbc1 CE |
98 | module cap (model="3D/RaleighAcorn_Filled_simple.stl", native_d = 168) { |
99 | scale_f = outer_d / native_d; //168; | |
100 | echo ("scale_f = ", scale_f); | |
244fc8f0 CE |
101 | difference () { |
102 | scale ([scale_f, scale_f, scale_f]) { | |
103 | difference () { | |
104 | union () { | |
b097fbc1 | 105 | translate ([0, 0, -1]) import (model); |
244fc8f0 | 106 | echo ("h = ", thread_height/scale_f); |
244fc8f0 | 107 | } |
b097fbc1 | 108 | // todo: only makes sense for RaleighAcorn, fix in original model... |
244fc8f0 | 109 | translate ([0, 0, -0.51]) cube ([200, 200, 1], center=true); |
0cbf5490 | 110 | } |
0cbf5490 | 111 | } |
244fc8f0 | 112 | if (keychain) cap_keychain_holes (); |
b097fbc1 | 113 | |
1b73bd8e | 114 | // hollow the cap out (make parametric later, this is pretty ugly now, but calc seems to be ok for RaleighAcorn) |
b097fbc1 | 115 | diam_to_height_ratio = 3.2; |
1b73bd8e | 116 | dome_h = (dome_h == AUTO_CALCULATE) ? outer_d / diam_to_height_ratio - thread_height : dome_h; |
b097fbc1 CE |
117 | echo ("dome_h = ", dome_h); |
118 | difference () { | |
119 | translate ([0, 0, thread_height-0.01]) dome (d=outer_d, h=dome_h); | |
120 | } | |
121 | ||
122 | ||
2d35a865 CE |
123 | if (thread_height != 0) { |
124 | translate ([0, 0, -0.01]) acorn_thread (internal = true, ring = false); | |
125 | } | |
0cbf5490 | 126 | } |
0cbf5490 | 127 | } |
28ef71df | 128 | |
244fc8f0 CE |
129 | module gasket (gasket_height=0.9) { |
130 | cylinder (d = outer_d, h = gasket_height, center=true); | |
28ef71df CE |
131 | } |
132 | ||
244fc8f0 | 133 | module nuts () { |
5d6b539a CE |
134 | if (contains ("body", acorn_parts)) |
135 | translate ([outer_d+10, 0, 0,]) nut (); | |
136 | if (contains ("cap", acorn_parts)) | |
b097fbc1 | 137 | cap (native_d=167);//model="3D/RaleighAcorn_ExaggeratedCap_Decimated.stl", native_d = 178); |
5d6b539a CE |
138 | if (contains ("gasket", acorn_parts)) |
139 | translate ([-(outer_d+10), 0, 0,]) gasket (); | |
244fc8f0 | 140 | } |
28ef71df | 141 | |
244fc8f0 | 142 | nuts (); |
28ef71df | 143 | } |
244fc8f0 | 144 | |
b097fbc1 CE |
145 | //$fs = 1; |
146 | //$fa = 1; | |
244fc8f0 | 147 | |
b097fbc1 CE |
148 | acorn_parts = [ "cap"]; |
149 | ||
150 | //acorn (); | |
151 | huge_acorn (); | |
5d044ff6 CE |
152 | module medium_acorn () { |
153 | // older slightly larger model. | |
154 | acorn (inner_d = 26, base_height=20); | |
155 | } | |
b097fbc1 CE |
156 | |
157 | module huge_acorn () { | |
158 | acorn (inner_d=100, base_height=80, | |
159 | thread_size=4, thread_pitch=4, thread_height=8, | |
160 | keychain=false); | |
161 | } |