chiark / gitweb /
381176952b226251949850863272dcd938efc3c8
[reprap-play.git] / ksafe-base.scad
1 // -*- C -*-
2
3 // from actual ksafe
4 bolt_above = 8.50 - 0.50;
5 bolthole_height = 4.24 + 1.00;
6 wall_thick = 4.50;
7 bolthole_width = 16.62 + 2.00;
8 main_sz = 150.56 + 0.75;
9 cnr_rad = 13.5; // approx
10 lidinner_thick_allow = 20.78 + 0.50;
11
12 dpp3 = [ -5.5, 8.5 ];
13 dpp2 = [ -11.0, 7.0 ];
14 dpp1 = [ -34.0, 14.0 ];
15
16 // other parameters
17 web_thick = 4;
18 web_height = 20; // excluding wall and base thick
19 bolthole_rhs = 20;
20 bolthole_lhs = 20;
21 boltreinf_thick = 6;
22 anchor_wall_space = 25;
23 base_thick = 4;
24 space = 25;
25 anchor_thick = 4;
26 anchor_rad = 4;
27 bevel = 8;
28 string_slot = 3.0;
29 string_depth = 6.0;
30 thumbslot_depth = 5.0;
31 thumbslot_width = 15.0;
32 thumbslot_between = 10;
33 dcover_endthick = 3.0;
34 dcover_mainthick = 5.0;
35 dcover_slop_height = 0.25;
36 dcover_slop_depth = 0.25;
37 dcover_slop_inside = 1.25;
38
39 // ----- calculated -----
40
41 hsz = main_sz/2;
42
43 gppA = [0,0];
44 gppB = gppA - [ wall_thick, 0 ];
45
46 gppL = [ gppB[0], -(lidinner_thick_allow + space + base_thick) ];
47
48 yw1 = -web_thick/2;
49 yw2 = yw1 - bolthole_rhs;
50 yw3 = yw2 - anchor_thick;
51 yw4 = yw3 - anchor_wall_space;
52 yw5 = yw4 - wall_thick;
53 yw6 = -(hsz - cnr_rad + 0.1);
54
55 yw10 = web_thick/2;
56 yw11 = yw2 + anchor_wall_space;
57 yw12 = yw11 + wall_thick;
58 yw13 = -yw6;
59
60 // anchor
61
62 anchor_b = anchor_thick + anchor_rad;
63 appM = gppL + anchor_b * [1,1];
64
65 a_bevel = 2 * anchor_b * (1 + sqrt(0.5));
66
67 module upp_app_Vars(t_bevel){
68   $xppE = gppL + t_bevel * [0,1];
69   $xppF = gppL + t_bevel * [1,0];
70
71   $xppJ = $xppE + wall_thick * [ 1, tan(22.5) ];
72   $xppI = $xppF + base_thick * [ tan(22.5), 1 ];
73
74   // must pass a_bevel for t_bevel for these to be valid
75   $gppP = gppA + [0,-1] * lidinner_thick_allow;
76   $gppQ = $gppP + [1,-1] * web_height;
77   $gppR = $xppJ + [ 1, tan(22.5) ] * web_height;
78   $gppS = $xppI + [ tan(22.5), 1 ] * web_height;
79   $gppT = [ $gppQ[0], $xppE[1] ];
80
81   children();
82 }
83
84 module upp_app_Profile(){
85   polygon([ gppA,
86             gppB,
87             $xppE,
88             $xppF,
89             $xppF + [1,0],
90             $xppI + [1,0],
91             $xppJ ],
92           convexity=10);
93 }
94
95
96 module UsualProfile(){
97   upp_app_Vars(bevel) upp_app_Profile();
98 }
99
100 module NearAnchorProfile(){
101   upp_app_Vars(a_bevel) upp_app_Profile();
102 }
103
104 module AnchorProfile(){
105   upp_app_Vars(a_bevel) {
106
107     upp_app_Profile();
108
109     difference(){
110       hull(){
111         polygon([ $xppE,
112                   $xppF,
113                   $xppF + [0,1],
114                   $xppE + [1,0] ],
115           convexity=10);
116         translate(appM) circle(r= anchor_b);
117       }
118       translate(appM) circle(r= anchor_rad);
119     }
120   }
121 }
122
123 module AnchorWallProfile(){
124   UsualProfile();
125   NearAnchorProfile();
126   hull(){
127     for (bev = [bevel, a_bevel]) {
128       upp_app_Vars(bev) {
129         polygon([ $xppE,
130                   $xppF,
131                   $xppI,
132                   $xppJ ],
133           convexity=10);
134       }
135     }
136   }
137 }
138
139 module WebProfile(){
140   upp_app_Vars(a_bevel){
141     if ($gppR[1] <= $gppP[1]) {
142       polygon([ $gppP,
143                 $xppE,
144                 $gppT,
145                 $gppQ ]);
146       polygon([ $gppP,
147                 $xppE,
148                 $xppF,
149                 $gppS,
150                 $gppR ],
151           convexity=10);
152     } else {
153       polygon([ $gppP,
154                 $xppE,
155                 $xppF,
156                 $gppS,
157                 $gppP + web_height * [1,0] ],
158           convexity=10);
159     }
160     polygon([ $gppS,
161               $xppF,
162               $xppF + [1,0],
163               $gppS + [1,0] ],
164           convexity=10);
165   }
166 }
167
168 module SomeBaseProfile(I, F){
169   polygon([ I,
170             F,
171             [ hsz+1, F[1] ],
172             [ hsz+1, I[1] ] ]);
173 }
174
175 module BaseProfile(){
176   SomeBaseProfile($xppI, $xppF);
177 }
178
179 module SWalls(ymin, ymax, t_bevel) {
180   upp_app_Vars(t_bevel) {
181     translate([0,ymin,0])
182       mirror([0,1,0])
183       rotate([90,0,0])
184       linear_extrude(height= ymax-ymin, convexity=10)
185       for (xm=[0,1])
186         mirror([xm,0])
187           translate([-hsz, 0])
188             children();
189   }
190 }
191
192 module AtTwoCorners(){
193   for (xm=[0,1]) {
194     mirror([xm,0,0]) 
195     translate((hsz - cnr_rad) * [1,1])
196     intersection(){
197       rotate_extrude(convexity=10)
198         translate([-cnr_rad,0])
199         children();
200       translate([0,0,-250])
201         cube([50,50,500]);
202     }
203   }
204 }
205
206 module Box(){
207   /// corners, and front and back of base
208   for (ym=[0,1]) mirror([0,ym,0]) {
209     AtTwoCorners(){
210       UsualProfile();
211     }
212     hull() AtTwoCorners(){
213       upp_app_Vars(bevel){
214         polygon([ $xppI,
215                   $xppF,
216                   $xppF + [0.1, 0],
217                   $xppI + [0.1, 0]
218                   ]);
219       }
220     }
221   }
222
223   // side walls and base
224   SWalls(yw6 , yw4 , bevel  ) { UsualProfile();      BaseProfile(); }
225   SWalls(yw5 , yw4 , a_bevel) { AnchorWallProfile(); BaseProfile(); }
226   SWalls(yw5 , yw12, a_bevel) { NearAnchorProfile(); BaseProfile(); }
227   SWalls(yw3 , yw2 , a_bevel) { AnchorProfile();     BaseProfile(); }
228   SWalls(yw11, yw12, a_bevel) { AnchorWallProfile(); BaseProfile(); }
229   SWalls(yw11, yw13, bevel  ) { UsualProfile();      BaseProfile(); }
230   SWalls(yw1,  yw10, a_bevel) { WebProfile(); SomeBaseProfile($gppS, $xppF); }
231
232   // front and rear walls
233   rotate([0,0,90]) SWalls(yw6, yw13, bevel) UsualProfile();
234 }
235
236 module KsafeBase(){ ////toplevel
237   cut = main_sz + 20;
238
239   difference(){
240     Box();
241
242     // bolt holes
243     translate([0,0, -bolt_above -0.5 * bolthole_height])
244       cube(center=true, [ cut, bolthole_width, bolthole_height ]);
245
246     // string slot
247     translate([ -cut,
248                 -(bolthole_width/2 + bolthole_rhs),
249                 1 ])
250       mirror([0,1,0]) mirror([0,0,1])
251       cube([ cut*2,
252              string_slot,
253              lidinner_thick_allow + string_depth + 1 ]);
254
255     // thumb slots
256     for (mx=[0,1]) mirror([mx,0,0]) {
257       translate([ thumbslot_between/2,
258                   0,
259                   -thumbslot_depth ])
260         cube([ thumbslot_width,
261                cut,
262                thumbslot_depth+1 ]);
263     }
264   }
265 }
266
267 module DemoProfiles(){ ////toplevel
268   translate([0,0,-2]) color("yellow") AnchorWallProfile();
269   color("red") AnchorProfile();
270   translate([0,0,2]) color("black") NearAnchorProfile();
271   translate([0,0,4]) color("blue") UsualProfile();
272   translate([0,0,-4]) color("pink") WebProfile();
273 }
274
275 module RimTest(){ ////toplevel
276   intersection(){
277     Box();
278     cube(center=true, [ main_sz*2, main_sz*2,
279                         2.5 ]);
280   }
281 }
282
283 module BoltTest(){ ////toplevel
284   dy = 0.5 * (bolthole_width+4);
285   intersection(){
286     KsafeBase();
287     translate([ 0, -dy, -(bolt_above + bolthole_height + 1) ])
288       cube([ main_sz, dy*2, 50 ]);
289   }
290 }
291
292 //DemoProfiles();
293 //Box();
294 //KsafeBase();
295 //RimTest();