chiark / gitweb /
ksafe-base: dcover wip
[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 ksafecover_lip = 4.62;
34 display_width = 69.81 - 0.50;
35 dcover_endthick = 3.0;
36 dcover_mainthick = 5.0;
37 dcover_slop_height = 0.35;
38 dcover_slop_depth = 0.25;
39 dcover_slop_inside = 1.50;
40 dcover_commonvertoff = 0.00; // slop_height or slop_inside is added too
41
42 // ----- calculated -----
43
44 hsz = main_sz/2;
45
46 gppA = [0,0];
47 gppB = gppA - [ wall_thick, 0 ];
48
49 gppL = [ gppB[0], -(lidinner_thick_allow + space + base_thick) ];
50
51 yw1 = -web_thick/2;
52 yw2 = yw1 - bolthole_rhs;
53 yw3 = yw2 - anchor_thick;
54 yw4 = yw3 - anchor_wall_space;
55 yw5 = yw4 - wall_thick;
56 yw6 = -(hsz - cnr_rad + 0.1);
57
58 yw10 = web_thick/2;
59 yw11 = yw2 + anchor_wall_space;
60 yw12 = yw11 + wall_thick;
61 yw13 = -yw6;
62
63 cpp1 = dpp1 + [  dcover_slop_depth, dcover_slop_height ];
64 cpp2 = dpp2 + [ -dcover_slop_depth, dcover_slop_height ];
65 cppH = cpp1 + [ 0, dcover_endthick ];
66 cppA = [ cpp2[0], dpp3[1] + dcover_slop_inside ];
67 cppK = cppA + [ 0, dcover_mainthick ];
68 cppZ = [ -ksafecover_lip, -dcover_commonvertoff ];
69 cppD = cppZ + [ 0, -dcover_slop_inside ];
70 cppE = cppD + [ 0, -dcover_mainthick ];
71 cppC = [ dcover_slop_inside, cppD[1] ];
72 cppF = cppC + dcover_mainthick * [1,-1];
73 cppB = [ cppC[0], cppA[1] ];
74 cppG = [ cppF[0], cppK[1] ];
75
76 // anchor
77
78 anchor_b = anchor_thick + anchor_rad;
79 appM = gppL + anchor_b * [1,1];
80
81 a_bevel = 2 * anchor_b * (1 + sqrt(0.5));
82
83 module upp_app_Vars(t_bevel){
84   $xppE = gppL + t_bevel * [0,1];
85   $xppF = gppL + t_bevel * [1,0];
86
87   $xppJ = $xppE + wall_thick * [ 1, tan(22.5) ];
88   $xppI = $xppF + base_thick * [ tan(22.5), 1 ];
89
90   // must pass a_bevel for t_bevel for these to be valid
91   $gppP = gppA + [0,-1] * lidinner_thick_allow;
92   $gppQ = $gppP + [1,-1] * web_height;
93   $gppR = $xppJ + [ 1, tan(22.5) ] * web_height;
94   $gppS = $xppI + [ tan(22.5), 1 ] * web_height;
95   $gppT = [ $gppQ[0], $xppE[1] ];
96
97   children();
98 }
99
100 module upp_app_Profile(){
101   polygon([ gppA,
102             gppB,
103             $xppE,
104             $xppF,
105             $xppF + [1,0],
106             $xppI + [1,0],
107             $xppJ ],
108           convexity=10);
109 }
110
111
112 module UsualProfile(){
113   upp_app_Vars(bevel) upp_app_Profile();
114 }
115
116 module NearAnchorProfile(){
117   upp_app_Vars(a_bevel) upp_app_Profile();
118 }
119
120 module AnchorProfile(){
121   upp_app_Vars(a_bevel) {
122
123     upp_app_Profile();
124
125     difference(){
126       hull(){
127         polygon([ $xppE,
128                   $xppF,
129                   $xppF + [0,1],
130                   $xppE + [1,0] ],
131           convexity=10);
132         translate(appM) circle(r= anchor_b);
133       }
134       translate(appM) circle(r= anchor_rad);
135     }
136   }
137 }
138
139 module AnchorWallProfile(){
140   UsualProfile();
141   NearAnchorProfile();
142   hull(){
143     for (bev = [bevel, a_bevel]) {
144       upp_app_Vars(bev) {
145         polygon([ $xppE,
146                   $xppF,
147                   $xppI,
148                   $xppJ ],
149           convexity=10);
150       }
151     }
152   }
153 }
154
155 module WebProfile(){
156   upp_app_Vars(a_bevel){
157     if ($gppR[1] <= $gppP[1]) {
158       polygon([ $gppP,
159                 $xppE,
160                 $gppT,
161                 $gppQ ]);
162       polygon([ $gppP,
163                 $xppE,
164                 $xppF,
165                 $gppS,
166                 $gppR ],
167           convexity=10);
168     } else {
169       polygon([ $gppP,
170                 $xppE,
171                 $xppF,
172                 $gppS,
173                 $gppP + web_height * [1,0] ],
174           convexity=10);
175     }
176     polygon([ $gppS,
177               $xppF,
178               $xppF + [1,0],
179               $gppS + [1,0] ],
180           convexity=10);
181   }
182 }
183
184 module SomeBaseProfile(I, F){
185   polygon([ I,
186             F,
187             [ hsz+1, F[1] ],
188             [ hsz+1, I[1] ] ]);
189 }
190
191 module BaseProfile(){
192   SomeBaseProfile($xppI, $xppF);
193 }
194
195 module DCoverProfileRaw(){
196   polygon([ cpp1,
197             cpp2,
198             cppA,
199             cppB,
200             cppC,
201             cppD,
202             cppE,
203             cppF,
204             cppG,
205             cppK,
206             cppH ],
207           convexity = 10);
208 }
209
210 module DCoverProfile(){
211   mirror([1,0])
212     translate(-cppZ)
213     DCoverProfileRaw();
214 }
215
216 module SWalls(ymin, ymax, t_bevel) {
217   upp_app_Vars(t_bevel) {
218     translate([0,ymin,0])
219       mirror([0,1,0])
220       rotate([90,0,0])
221       linear_extrude(height= ymax-ymin, convexity=10)
222       for (xm=[0,1])
223         mirror([xm,0])
224           translate([-hsz, 0])
225             children();
226   }
227 }
228
229 module AtTwoCorners(){
230   for (xm=[0,1]) {
231     mirror([xm,0,0]) 
232     translate((hsz - cnr_rad) * [1,1])
233     intersection(){
234       rotate_extrude(convexity=10)
235         translate([-cnr_rad,0])
236         children();
237       translate([0,0,-250])
238         cube([50,50,500]);
239     }
240   }
241 }
242
243 module Box(){
244   /// corners, and front and back of base
245   for (ym=[0,1]) mirror([0,ym,0]) {
246     AtTwoCorners(){
247       UsualProfile();
248     }
249     hull() AtTwoCorners(){
250       upp_app_Vars(bevel){
251         polygon([ $xppI,
252                   $xppF,
253                   $xppF + [0.1, 0],
254                   $xppI + [0.1, 0]
255                   ]);
256       }
257     }
258   }
259
260   // side walls and base
261   SWalls(yw6 , yw4 , bevel  ) { UsualProfile();      BaseProfile(); }
262   SWalls(yw5 , yw4 , a_bevel) { AnchorWallProfile(); BaseProfile(); }
263   SWalls(yw5 , yw12, a_bevel) { NearAnchorProfile(); BaseProfile(); }
264   SWalls(yw3 , yw2 , a_bevel) { AnchorProfile();     BaseProfile(); }
265   SWalls(yw11, yw12, a_bevel) { AnchorWallProfile(); BaseProfile(); }
266   SWalls(yw11, yw13, bevel  ) { UsualProfile();      BaseProfile(); }
267   SWalls(yw1,  yw10, a_bevel) { WebProfile(); SomeBaseProfile($gppS, $xppF); }
268
269   // front and rear walls
270   rotate([0,0,90]) SWalls(yw6, yw13, bevel) UsualProfile();
271 }
272
273 module KsafeBase(){ ////toplevel
274   cut = main_sz + 20;
275
276   difference(){
277     Box();
278
279     // bolt holes
280     translate([0,0, -bolt_above -0.5 * bolthole_height])
281       cube(center=true, [ cut, bolthole_width, bolthole_height ]);
282
283     // string slot
284     translate([ -cut,
285                 -(bolthole_width/2 + bolthole_rhs),
286                 1 ])
287       mirror([0,1,0]) mirror([0,0,1])
288       cube([ cut*2,
289              string_slot,
290              lidinner_thick_allow + string_depth + 1 ]);
291
292     // thumb slots
293     for (mx=[0,1]) mirror([mx,0,0]) {
294       translate([ thumbslot_between/2,
295                   0,
296                   -thumbslot_depth ])
297         cube([ thumbslot_width,
298                cut,
299                thumbslot_depth+1 ]);
300     }
301   }
302 }
303
304 module DemoProfiles(){ ////toplevel
305   translate([0,0,-2]) color("yellow") AnchorWallProfile();
306   color("red") AnchorProfile();
307   translate([0,0,2]) color("black") NearAnchorProfile();
308   translate([0,0,4]) color("blue") UsualProfile();
309   translate([0,0,-4]) color("pink") WebProfile();
310   translate([0,0,6]) color("purple") DCoverProfile();
311 }
312
313 module RimTest(){ ////toplevel
314   intersection(){
315     Box();
316     cube(center=true, [ main_sz*2, main_sz*2,
317                         2.5 ]);
318   }
319 }
320
321 module BoltTest(){ ////toplevel
322   dy = 0.5 * (bolthole_width+4);
323   intersection(){
324     KsafeBase();
325     translate([ 0, -dy, -(bolt_above + bolthole_height + 1) ])
326       cube([ main_sz, dy*2, 50 ]);
327   }
328 }
329
330 //DemoProfiles();
331 //Box();
332 //KsafeBase();
333 //RimTest();