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