chiark / gitweb /
poster-tube-lid: WallMountForBase wip
[reprap-play.git] / poster-tube-lid.scad
1 // -*- C -*-
2
3 // Print, for each end:
4 //
5 //   CoverPrint
6 //   StrapMount
7 //   CatchAssembly
8
9 include <funcs.scad>
10 include <utils.scad>
11
12 coarse = false;
13 enable_head_cups = false;
14
15 main_dia = 71.2 + 0.50 - 2.26;
16 top_thick_middle = 4;
17 top_thick_by_oring = 3.0;
18 top_middle_dr = 11;
19
20 main_cnr = 6.0;
21
22 min_wall = 3;
23
24 rivet_posn = 6.0 + 0.30;
25 rivet_thick = 1.67;
26 rivet_width = 4.15 + 1.0;
27 rivet_tall = 5.51 + 1.49;
28
29 over_rivet_wall = 1.0;
30 side_rivet_gap = 1.5;
31 inside_rivet_gap = 1.5;
32
33 bayo_interf = 0.30;
34 bayo_behind = 8.5;
35 bayo_interf_width = 2.0;
36 bayo_interf_slope = 0.5;
37
38 oring_thick = 5.0;
39 oring_bore = 62.0;
40
41 oring_upper_embed_angle = 80;
42 oring_compress = 0.1; // proportion
43 oring_compress_more = 0.2;
44
45 oring_rm_beside = 8;
46 oring_rm_scale = 2.0;
47 oring_rm_angle = 20;
48
49 side_taper = 1.0;
50
51 bayo_gap = 6.0;
52
53 bayo_entry = 1.167;
54 bayo_inramp = 0.9;
55
56 bayo_slice_size = coarse ? 5 : 1;
57
58 brace_hole_width = 1.0;
59 brace_above_below = 1.2;
60 brace_end_shorter = 0.3;
61
62 jig_thick = 1.4;
63 jig_hole_dia = 3.0;
64 jig_rim = 5;
65 jig_mark = 5;
66
67 strap_loop_thick = 6;
68 strap_loop_inside = 10;
69 strap_loop_strlen = 10;
70 strap_loop_elevation = 45;
71
72 sm_inner_circum = 218 - 1.90 - 1.00 - 0.50;
73 sm_main_thick = 2.0;
74 sm_main_width = 20;
75
76 sm_bolt_dia = 3.5 + 0.1;
77 sm_bolt_shaft = 21.0;
78 sm_bolt_head_dia = 6.94 + 1.0;
79 sm_bolt_head_thick = 2.14;
80 sm_bolt_nut_width = 5.89 + 0.25;
81 sm_bolt_nut_thick = 3.68;
82 sm_bolt_tighten_allow = 2.0;
83
84 sm_bolt_y_clear = 0.75;
85 sm_bolt_y_over = 0.5;
86
87 sm_closure_cnr = 3.0;
88
89 wm_thick = 5;
90 wm_screw_dia = 4.5; // XXX
91 wm_screwdriver_dia = 6.0; // XXX
92 wm_screw_around = 4.0; // XXX
93 wm_screw_slot = 3.5;
94 wm_screw_head = 7.5; // XXX
95
96 wmb_screw_dia = 5;
97 wmb_screw_around_x = 4; // XXX
98 wmb_screw_around_y = 6; // XXX
99 wmb_screw_depth = 10; // XXX
100 wmb_nut_across = 8; // XXX
101 wmb_nut_around_min = 2; // XXX
102 wmb_nut_th = 4; // XXX
103 wmb_gap = 1.0;
104
105 catch_stalk_h = 4.5;
106 catch_stalk_len = 50;
107 catch_tip_th = 4;
108 catch_head_th = 3;
109
110 catch_pin_slop = 0.25; // each side, and above
111 catch_pin_slop_x_extra = 0.0; // only on one side
112 catch_stalk_above_gap = 1.5;
113 catch_stalk_eff_bend_rad = catch_stalk_len * 0.75;
114
115 catch_strap_width = 12;
116 catch_stalk_base_width = 15;
117
118 catch_knob_dia = 6;
119 catch_knob_above_gap = 5;
120 catch_knob_height = 3.0;
121
122 catch_stalk_below_gap = 1.0;
123 catch_stalk_beside_gap = 2.0;
124
125 // calculated
126
127 TAU = PI*2;
128
129 bayo_entry_x = bayo_entry;
130 bayo_entry_z = bayo_entry;
131 bayo_inramp_x = bayo_inramp;
132 bayo_inramp_z = bayo_inramp;
133
134 oring_mid_dia = oring_bore + oring_thick;
135 oring_outer_dia = oring_mid_dia + oring_thick;
136
137 oring_oblate = (1 - oring_compress);
138
139 oring_y_rad = oring_thick/2 * oring_oblate;
140 oring_x_rad = oring_thick/2 / oring_oblate;
141
142 by_oring_z = oring_y_rad * (1 + cos(oring_upper_embed_angle));
143
144 side_height = rivet_posn + bayo_behind + rivet_thick/2;
145 side_thick = rivet_tall + over_rivet_wall;
146
147 top_z = top_thick_by_oring + oring_y_rad + by_oring_z;
148
149 middle_bot_z = top_z - top_thick_middle;
150
151 bayo_top_z = bayo_behind + bayo_gap;
152
153 bayo_nom_rad = main_dia/2 + side_thick;
154 bayo_real_rad = main_dia/2 + rivet_tall;
155
156 rivet_entry_width = rivet_width + side_rivet_gap;
157
158 jig_mark_rad = jig_mark + main_dia/2 + jig_thick;
159
160 handling_dia = oring_bore + oring_thick*2 + min_wall*2;
161 handling_angle = 45;
162
163 sm_inner_rad = (sm_inner_circum + sm_bolt_tighten_allow/2) / TAU;
164 sm_outer_rad = sm_inner_rad + sm_main_thick;
165
166 wm_main_width = sm_main_width;
167 wm_y_min = sqrt( pow(sm_inner_rad, 2) -
168                  pow(sm_inner_rad - (wm_thick - sm_main_thick), 2) );
169 wm_y_screw = wm_y_min + wm_screw_around + wm_screw_dia/2;
170 wm_y_max = wm_y_screw + wm_screw_dia/2 + wm_screw_around;
171 wm_y_slotc_screw = wm_y_screw + wm_screw_slot/2;
172 wm_y_slot1_screw = wm_y_screw + wm_screw_slot;
173 wm_y_slot1_max = wm_y_max + wm_screw_slot;
174 wm_z_slot0_screw = wm_main_width + wm_screwdriver_dia/2;
175 wm_z_slotc_screw = wm_z_slot0_screw + wm_screw_slot/2;
176 wm_z_slot1_screw = wm_z_slot0_screw + wm_screw_slot;
177 wm_z_max = wm_z_slot1_screw + wm_screw_around;
178
179 wmb_mount_cut_rad = sm_outer_rad + wmb_gap;
180 wmb_x_screw = -sm_outer_rad + max(
181                                   wmb_screw_around_x + wmb_screw_dia/2,
182                                   wmb_nut_around_min + wmb_nut_across/2
183                                   );
184 function wmb_screw_thing_y_min(dia) = sqrt(
185                        pow(wmb_mount_cut_rad, 2) -
186                        pow(wmb_x_screw + dia/2, 2)
187                        );
188 wmb_y_screw_end = wmb_screw_thing_y_min(wmb_screw_dia);
189 wmb_y_nut_min = wmb_screw_thing_y_min(wmb_nut_across + wmb_nut_around_min*2);
190 wmb_z_screw = 10; // XXX
191
192 smc_pos = [ 0, sm_inner_rad, 0 ];
193
194 smc_bolt_nut_dia = sm_bolt_nut_width / cos(30);
195 smc_bolt_nut_eff_thick = sm_bolt_nut_thick + sm_bolt_tighten_allow;
196
197 smc_bolt_y = sm_bolt_dia/2 + sm_bolt_y_clear;
198 smc_max_y = smc_bolt_y + sm_bolt_y_over
199   + max(sm_bolt_head_dia/2, smc_bolt_nut_dia/2);
200 smc_cnr_c_x = sm_bolt_shaft/2 - sm_closure_cnr
201   + sm_bolt_head_thick/2 + smc_bolt_nut_eff_thick/2;
202
203 catch_cr = catch_knob_dia/2 + catch_stalk_beside_gap;
204 catch_strap_thick = sm_main_thick;
205
206 echo("R ", sm_inner_rad, bayo_real_rad, bayo_nom_rad);
207
208 $fs= coarse ? 2.5 : 0.5;
209 $fa= coarse ? 5 : 1;
210
211 include <poster-tube-lid-parametric.scad>
212
213 // bayonet definition
214
215 bayo_a = [ bayo_entry_x, 0 ];
216 bayo_p = [ 0, bayo_entry_z ];
217 bayo_n = [ 0, bayo_behind-bayo_inramp_z ];
218 bayo_m = [ bayo_inramp_x, bayo_behind ];
219 bayo_l = bayo_m + bayo_interf * [ 1/bayo_interf_slope,  1 ];
220 bayo_k = bayo_l + [ bayo_interf_width, 0 ];
221 bayo_j = bayo_k + bayo_interf * [ 1/bayo_interf_slope, -1 ];
222 bayo_i = bayo_j + [ rivet_width + inside_rivet_gap, 0 ];
223 bayo_h = [ bayo_i[0], bayo_behind + bayo_gap + bayo_interf ];
224 bayo_g = [ bayo_m[0] - rivet_width, bayo_h[1] ];
225
226 bayo_e = [-bayo_p[0], bayo_p[1]] - [rivet_entry_width,0];
227 bayo_d = [-bayo_a[0], bayo_a[1]] - [rivet_entry_width,0];
228 bayo_c = bayo_d + [0,-5];
229 bayo_b = bayo_a + [0,-5];
230
231 bayo_f = [ bayo_e[0], bayo_g[1] + (bayo_e[0] - bayo_g[0]) ];
232
233 bayo_polygon = [ bayo_a,
234                  bayo_b,
235                  bayo_c,
236                  bayo_d,
237                  bayo_e,
238                  bayo_f,
239                  bayo_g,
240                  bayo_h,
241                  bayo_i,
242                  bayo_j,
243                  bayo_k,
244                  bayo_l,
245                  bayo_m,
246                  bayo_n,
247                  bayo_p ];
248
249 echo(bayo_polygon);
250
251 // CATCH
252
253 cppxC = 0.41 * sm_inner_rad * TAU;
254
255 // catch pin
256
257 cpp_adj = (bayo_n[0] - bayo_f[0]) * (1 - sm_inner_rad / bayo_nom_rad);
258 // radius scaling due to nom and actual radius difference in
259 // bayo entry construction
260
261 cppa = bayo_f + [1,-1] * catch_pin_slop + [1,0] * cpp_adj;
262 cppb = bayo_g + [1,-1] * catch_pin_slop + [1,0] * cpp_adj;
263 cppd = [ bayo_n[0]
264          - catch_pin_slop - catch_pin_slop_x_extra,
265          -catch_stalk_above_gap ];
266 cppi = [ cppa[0], cppd[1] ];
267 cppc = [ cppd[0], cppb[1] ];
268 cpph = cppd + [0,-1] * catch_stalk_h;
269 cppe = cppd + [0,-1] * (catch_knob_above_gap + catch_knob_dia/2);
270 cppf = [ cppa[0], cppe[1] ];
271 cppg = [ cppa[0], cpph[1] ];
272 cppB = 0.5 * (cppf + cppe);
273
274 echo("RR", sm_inner_rad / bayo_nom_rad);
275
276 // catch assembly depression below pin
277
278 cppy6 = cppB[1] - (catch_knob_dia/2
279                    + (cppc[1] - cppd[1])
280                    + catch_stalk_below_gap);
281 cpp7 = [ cppB[0], cppy6 + catch_cr ];
282 cpp11 = cpp7 + [1,0] * catch_cr;
283 cppy9 = cppy6 + catch_strap_width * 1/3;
284 cpp9 = [ cpp7[0] + catch_cr * 2, cppy9 ];
285 cpp8 = cpp9 + [0,-1] * catch_cr;
286 cpp10 = cpp8 + [-1,0] * catch_cr;
287 cppC = [ cppxC, cpp9[1] ];
288 cppD = cppC + [0,-1] * catch_strap_width;
289
290 // catch assembly stalk and so on
291
292 catch_cr3 = catch_cr + catch_stalk_h;
293
294 cppF = [ cppg[0] - catch_stalk_eff_bend_rad, cppd[1] ];
295 cpp4 = [ cppg[0] - catch_stalk_len, cpph[1] ] + [1,-1] * catch_cr;
296 cpp5 = [ cpp4[0], cppC[1] + catch_cr ];
297 cpp2 = cpp5 + [-1,0] * (catch_cr * 2 + catch_stalk_base_width);
298 cpp2r = cpp2 + [1,0] * catch_cr;
299 cpp2d = cpp2 + [0,-1] * catch_cr;
300 cpp3 = [ cpp2[0] + catch_cr + catch_cr3, cppd[1] - catch_cr3 ];
301 cppA = [ -cppxC, cpp9[1] ];
302 cppE = [ cppA[0], cppD[1] ];
303
304 catch_assembly_dy = -cppy9 + catch_strap_width;
305
306
307 module MainProfile(){
308   main_cnr_pos = [ side_thick, top_z ] - [1,1]*main_cnr;
309   difference(){
310     union(){
311       translate(main_cnr_pos){
312         intersection(){
313           difference(){
314             circle(r = main_cnr);
315             circle(r = main_cnr * 0.5);
316           }
317           square([10,10]);
318         }
319       }
320       polygon([[ -top_middle_dr,        middle_bot_z      ],
321                [ -top_middle_dr,        top_z             ],
322                [ main_cnr_pos[0],       top_z             ],
323                [ side_thick,            main_cnr_pos[1]   ],
324                [ side_thick,            -side_height      ],
325                [ side_taper,            -side_height      ],
326                [ 0,                     -rivet_posn       ],
327                [ 0,                     by_oring_z        ],
328                [ -oring_x_rad,          by_oring_z        ],
329                ],
330               convexity=10);
331     }
332     translate([ oring_mid_dia/2 - main_dia/2, 0 ])
333       hull(){
334       translate([ 0, oring_y_rad ])
335         scale([ 1/oring_oblate * (oring_compress_more+1) , oring_oblate ])
336         circle(oring_thick/2);
337       translate([ 0, oring_y_rad*2 - oring_thick/2 ])
338         circle(oring_thick/2);
339     }
340   }
341 }
342
343 module StrapLoopProfile(){
344   circle(r = strap_loop_thick/2);
345 }
346
347 module StrapLoop(){ ////toplevel
348   bigrad = strap_loop_inside/2 + strap_loop_thick/2;
349   extralen = strap_loop_thick * 5;
350
351   intersection(){
352     rotate([strap_loop_elevation, 0,0]){
353       for (x= [ -1, +1 ] * bigrad) {
354         translate([x, -extralen, 0])
355           rotate([-90,0,0])
356           linear_extrude(height= extralen + strap_loop_strlen + 0.1,
357                          convexity=10)
358           StrapLoopProfile();
359       }
360       translate([0, strap_loop_strlen, 0]){
361         intersection(){
362           rotate_extrude(convexity=10)
363             translate([bigrad, 0,0])
364             StrapLoopProfile();
365           translate([0,50,0])
366             cube([100,100,100], center=true);
367         }
368       }
369     }
370     translate([0, 50, 0])
371       cube(100, center=true);
372   }
373 }
374
375 module RotateProjectSlice(offset, slice_size, nom_rad, real_rad){
376   // nom_rad > real_rad
377   rotate([0,0, atan2(offset, nom_rad) ]){
378     intersection(){
379       translate([-offset, -10, 0])
380         rotate([90,0,0])
381         linear_extrude(height= nom_rad*2, convexity=50)
382         children(0);
383       translate([0,0, -25])
384         cylinder(h=50, r= real_rad);
385       translate([0,0, -25])
386         linear_extrude(height= 50, convexity=50)
387         polygon([ [ 0,0 ],
388                   [ -slice_size, -real_rad*2 ],
389                   [ +slice_size, -real_rad*2 ] ]);
390     }
391   }
392 }
393
394 module RotateProject(x_min, x_max, slice_size, nom_rad, real_rad){
395   offs = [ for (i=[ x_min :
396                     slice_size :
397                     x_max + slice_size ]) i ];
398   echo (offs);
399   for (off=offs)
400     RotateProjectSlice(off, slice_size, nom_rad, real_rad)
401     children(0);
402 }
403
404 module BayonetCutout(){
405   RotateProject(bayo_c[0], bayo_i[0], bayo_slice_size,
406                 bayo_nom_rad, 
407                 bayo_real_rad)
408     translate([-0.5 * (bayo_a[0] + bayo_d[0]), 0])
409     polygon(bayo_polygon, convexity=10);
410 }
411
412 module ProfilesDemo(){ ////toplevel
413   translate([-10,0]) MainProfile();
414   translate([+10, -side_height]) polygon(bayo_polygon, convexity=10);
415 }
416
417 module LimitForHandling(){ ////toplevel
418   hull() for (r=[0,180])
419     rotate([0,0,r]) {
420       for (rs=[-1,+1]) {
421         for (xd=[0,1]) {
422           rotate([0,0, rs * handling_angle/2]) {
423             translate([rs * xd * main_dia/2 * tan(handling_angle/2),
424                        main_dia/2 + side_thick - main_cnr,
425                        top_z - main_cnr]) {
426               mirror([0,0,1])
427                 cylinder(r= main_cnr, h=50);
428               sphere(main_cnr);
429             }
430           }
431         }
432       } 
433     }
434   hull() rotate_extrude(convexity=10){
435     translate([ handling_dia/2 - main_cnr, top_z - main_cnr ]) {
436       circle(r = main_cnr);
437       mirror([0,1]) square([ main_cnr, 50 ]);
438     }
439   }
440   //cylinder(r= handling_dia/2, h=20);
441 }
442
443 module Cover(){ ////toplevel
444   render() difference(){
445     intersection(){
446       union(){
447         rotate_extrude(convexity=10)
448           translate([main_dia/2, 0])
449           MainProfile();
450         translate([0,0, middle_bot_z])
451           cylinder(h= top_thick_middle, r = main_dia/2 - top_middle_dr + 1);
452       }
453       LimitForHandling();
454     }
455     for (r=[0,180]){
456       rotate([0,0, r])
457         translate([0,0, -side_height])
458         BayonetCutout();
459       rotate([0,0, r + asin((-oring_rm_beside) / (main_dia/2))])
460         translate([0,
461                    oring_mid_dia/2 + oring_thick/4 * oring_rm_scale,
462                    oring_y_rad * 1.5])
463         rotate([-oring_rm_angle, 0, 0])
464         mirror([0,0,1])
465         cylinder(r = oring_thick/4 * oring_rm_scale, h=20);
466     }
467     for (r=[0 : 60 : 179]) {
468       rotate([0,0, r]) {
469         height = top_thick_middle - brace_above_below*2;
470         translate([0,0, middle_bot_z + brace_above_below + height/2 ])
471         cube(center=true, [ oring_bore - brace_end_shorter,
472                             brace_hole_width, height ]);
473       }
474     }
475   }
476   if (enable_head_cups)
477     for (r=[0,180])
478       rotate([0,0,r])
479         translate([-implheadcup_large_dia * .5 - implheadcup_thick/2,
480                    -implheadcup_large_dia * .0,
481                    middle_bot_z + 0.1])
482         ImplHeadCup();
483
484 //  translate(strap_loop_thick * [-0.5, 0, +1])
485 //    translate([handling_dia/2, 0, -side_height])
486 //    rotate([0,180,0]) rotate([0,0,90])
487 //    StrapLoop();
488 }
489
490 module SavingHole(){
491   translate([0,0, -10])
492     cylinder(r= main_dia/2 - jig_rim, h=20);
493 }
494
495 module Jig(){ ////toplevel
496   difference(){
497     union(){
498       translate([0,0, -side_height]){
499         cylinder(r= main_dia/2 + jig_thick, h= side_height + jig_thick);
500       }
501       translate([-jig_mark_rad, 0, jig_thick - jig_mark])
502         cube([jig_mark_rad*2, jig_mark, jig_mark]);
503     }
504     translate([0,0, -side_height-1])
505       cylinder(r= main_dia/2, h= side_height + 1);
506     SavingHole();
507     translate([0,0, -rivet_posn])
508       rotate([90, 0,0])
509       translate([0,0, -100])
510       cylinder(r= jig_hole_dia/2, h = 200);
511   }
512 }
513
514 module CoverPrint(){ ////toplevel
515   rotate([0,180,0]) Cover();
516 }
517
518 module CoverTest2(){ ////toplevel
519   difference(){
520     Cover();
521     SavingHole();
522   }
523 }
524
525 module CoverTest1(){ ////toplevel
526   difference(){
527     CoverTest2();
528     difference(){
529       for (r= [ 40, 147 ]){
530         rotate([0,0, r]){
531           translate([0,0, -10]) {
532             cube([ main_dia*3, main_dia * .53, 18], center=true);
533           }
534         }
535       }
536 //      translate([ 50, 0, 0 ])
537 //      cube([ 100,
538 //             strap_loop_inside + strap_loop_thick*2 + 1,
539 //             100 ],
540 //           center=true);
541     }
542   }
543 }
544
545 module ImplHeadCupTest(){ ////toplevel
546   for (r=[0,180])
547     rotate([0,0,r])
548       translate([-17,0,0])
549       ImplHeadCup();
550 }
551
552 module SomeStrap(width, cut_width=0){
553   // children(0) is to add, (1) subtract
554   difference(){
555     union(){
556       cylinder(r=sm_outer_rad, h=width);
557       StrapMountProtrusion(smc_cnr_c_x + sm_closure_cnr,
558                            smc_max_y,
559                            sm_closure_cnr,
560                            width);
561       children(0);
562     }
563     translate([0,0,-1])
564       cylinder(r=sm_inner_rad, h=max(width+2, cut_width));
565     translate(smc_pos)
566       StrapMountBolt(10, width);
567     translate(smc_pos)
568       cube([ sm_bolt_tighten_allow, 40,100 ], center=true);
569     children(1);
570   }
571 }
572
573 module StrapMountBolt(l_delta, strap_width){ ///toplevel
574   // positioned relative to smc_pos
575   translate([(smc_bolt_nut_eff_thick - sm_bolt_head_thick)/2,
576              smc_bolt_y,
577              strap_width/2]){
578     translate([ -sm_bolt_shaft/2-1, 0,0 ]){
579       rotate([0,90,0]) cylinder(r= sm_bolt_dia/2, h= sm_bolt_shaft+2);
580     }
581     translate([ -sm_bolt_shaft/2, 0,0 ])
582       rotate([0,-90,0])
583       cylinder($fn=6, r=smc_bolt_nut_dia/2,
584                h=smc_bolt_nut_eff_thick + l_delta);
585     translate([ sm_bolt_shaft/2, 0,0 ])
586       rotate([0,90,0])
587       cylinder(r=sm_bolt_head_dia/2, h=sm_bolt_head_thick + l_delta);
588   }
589 }
590
591 module StrapMountProtrusion(half_x, max_y, cnr, width){
592   translate(smc_pos){
593     linear_extrude(height=width, convexity=10){
594       hull(){
595         for (m = [0,1]) mirror([m,0,0]) {
596           translate([-(half_x - cnr), max_y - cnr])
597             circle(r=cnr);
598           translate([-half_x, -sm_inner_rad])
599             square([1,1]);
600         }
601       }
602     }
603   }
604 }
605
606 module StrapMount(){ ////toplevel
607   SomeStrap(sm_main_width){
608     rotate([0,0,180]){
609       StrapMountProtrusion(strap_loop_inside/2 + strap_loop_thick,
610                            strap_loop_thick,
611                            sm_closure_cnr,
612                            sm_main_width);
613       translate(smc_pos +
614                 [0,0, sm_main_width] +
615                 strap_loop_thick * [ 0, 0.5, -1.0 ])
616         StrapLoop();
617     }
618     union(){ };
619   }
620 }
621
622 module WallScrewHoleSlot(){ ////toplevel
623   ds = [-1,+1] * wm_screw_slot/2;
624   linextr_x_yz(-(wm_thick + 1), 1) {
625     hull(){
626       for (d = ds)
627         translate([d, 0])
628           circle(r = wm_screw_dia/2);
629     }
630   }
631   hull(){
632     for (d = ds){
633       translate([0, d, 0]){
634         linextr_x_yz(0, 1)
635           circle(r = wm_screw_head/2);
636         linextr_x_yz(-(wm_screw_head - wm_screw_dia)/2, 0)
637           circle(r = wm_screw_dia/2);
638       }
639     }
640   }
641 }
642
643 module WallMountMounts(){
644   linextr(0, wm_z_max){
645     translate([ -sm_outer_rad, 0 ])
646       rectfromto([ 0, -wm_y_max ],
647                  [ wm_thick, wm_y_slot1_max ]);
648   }
649 }
650 module WallMountScrewHoles(){
651   translate([ -sm_outer_rad + wm_thick, 0, wm_z_slotc_screw]) {
652     translate([ 0, wm_y_slotc_screw, 0 ])
653       WallScrewHoleSlot();
654     translate([ 0, -wm_y_slotc_screw, 0 ])
655       rotate([90,0,0])
656       WallScrewHoleSlot();
657   }
658 }
659
660 module WallMount(){ ////toplevel
661   SomeStrap(sm_main_width, wm_z_max + 2){
662     WallMountMounts();
663     WallMountScrewHoles();
664   }
665 }
666
667 module WallMountBaseMounts(){
668 }
669
670 // screws, nuts, slots for nuts to go down into
671 module WallMountBaseScrewsEtc(){
672   for (my=[0,1]) {
673     mirror([0, my, 0]) {
674       translate([wmb_x_screw, 0, wmb_z_screw]) {
675         linextr_y_xz(wmb_y_screw_end,
676                      wmb_y_screw_end + wmb_screw_depth)
677           circle(r = wmb_screw_dia/2);
678         linextr_y_xz(wmb_y_nut_min,
679                      wmb_y_nut_min + wmb_nut_th){
680           hull(){
681             rotate(30)
682               circle(r = wmb_nut_across / cos(30) * 0.5, $fn = 6);
683             translate([0, 100]) // XXX change 100
684               square(wmb_nut_across, center=true);
685           }
686         }
687       }
688     }
689   }
690 }
691 /*
692   
693
694       linextr(wmb_y_screw_end
695       linextr(0, 20) {
696         difference(){
697           translate([ wmb_x_screw, wmb_y_screw_end ])
698             rectfromto([ -wmb_screw_dia/2, 0 ],
699                        [ +wmb_screw_dia/2, wmb_screw_depth ]);
700         }
701       }
702     }
703   }
704 }*/
705 //        circle(r = wmb_mount_cut_rad);
706
707 module WallMountForBase(){ ////toplevel
708   SomeStrap(sm_main_width, wm_z_max + 2){
709     union(){
710       WallMountMounts();
711     }
712     union(){
713       WallMountScrewHoles();
714       %WallMountBaseScrewsEtc();
715     }
716   }
717 }
718
719 module CatchAssemblyCoreProfile(){
720   difference(){
721     union(){
722       hull(){
723         translate(cpp3) circle(r= catch_cr3);
724         polygon([ cpp3,
725                   cpp2r,
726                   cpp5,
727                   cpph,
728                   cppd
729                   ]);
730       }
731       polygon([cppD,
732                cppC,
733                cpp9,
734                cpp10,
735                cpp11,
736                cpp4,
737                cpp2r,
738                cpp2d,
739                cppA,
740                cppE
741                ]);
742       translate(cpp8) circle(r= catch_cr);
743     }
744     hull(){
745       translate(cpp4) circle(r= catch_cr);
746       translate(cpp5) circle(r= catch_cr);
747       translate(cpp7) circle(r= catch_cr);
748       polygon([cpp4,
749                cppg,
750                cpph,
751                cpp10,
752                cpp11,
753                ]);
754     }
755     translate(cpp2) circle(r= catch_cr);
756   }
757   // if cpp11 is above cpp10, the subtracted hull above
758   // can go down too far.  Ensure we do not cut off below cppy6.
759   polygon([ cppE,
760             cppD,
761             cpp9,
762             [ cpp9[0],            cppy6 ],
763             [ cpp7[0] - catch_cr, cppy6 ],
764             cpp2d
765             ]);
766 }
767
768 module CatchTipProfile(dy){
769   ddy = [0,dy];
770   intersection(){
771     translate(cppF){
772       difference(){
773 //      circle(r = dist2d(cppF, cppd));
774         //circle(r = dist2d(cppF, cppa));
775       }
776     }
777     polygon([ cppa,
778               cppi + ddy,
779               cppd + ddy,
780               cppc,
781               cppb ]);
782   }
783 }
784
785 module CatchHeadProfile(){
786   polygon([ cppd,
787             cppd,
788             cppi,
789             cppf,
790             cppe,
791             cpph ]);
792 }
793
794
795 module CatchCore(){ /////toplevel
796   linear_extrude(height=catch_strap_thick, convexity=10)
797     CatchAssemblyCoreProfile();
798
799   hull(){
800     linear_extrude(height=catch_head_th, convexity=10)
801       CatchTipProfile(0);
802     linear_extrude(height=catch_tip_th, convexity=10)
803       CatchTipProfile(catch_tip_th - catch_head_th);
804   }
805
806   linear_extrude(height=catch_head_th, convexity=10)
807     CatchHeadProfile();
808
809   translate(concat(cppB,[0])) hull(){
810     translate([0,0, catch_knob_height + catch_head_th - catch_knob_dia/2])
811       sphere(r = catch_knob_dia/2);
812     cylinder(r = catch_knob_dia/2, h = 0.1);
813   }
814 }
815
816 module CatchPreDistort(){ /////toplevel
817   scale(100 / sm_inner_rad)
818     rotate([90,0,0])
819     CatchCore();
820 }
821
822 module CatchAssembly(){ /////toplevel
823   rotate([0,0, -(cppe[0] + cppB[0] + catch_pin_slop) / sm_inner_rad * 360/TAU])
824     translate([0,0, catch_assembly_dy])
825     scale(sm_inner_rad / 100)
826     import(str("poster-tube-lid,CatchPostDistort-fa",
827                (coarse ? 20 : 3),
828                ".stl"),
829            convexity=20);
830
831   SomeStrap(catch_strap_width){
832     union(){ }
833     union(){
834       translate([-200, -200, -200])
835         cube([400, 200, 400]);
836     }
837   }
838 }
839
840 module CatchDemo(){ /////toplevel
841   color("blue") translate([0,0,
842                            -catch_assembly_dy
843              ])
844     CatchAssembly();
845   translate([0,0,+side_height
846              ])
847     Cover();
848 }
849
850 module CatchDemoS(){ /////toplevel
851   color("blue") translate([0,0,
852              -catch_assembly_dy
853              ])
854     CatchAssembly();
855   intersection(){
856     translate([0,0,+side_height
857                ])
858       Cover();
859     mirror([0,1,0]) translate([-250,33,0]) cube([500,500,500]);
860   }
861   color("black")
862     translate([0,-33,0])
863     cube([6.15, 2,2], center=true);
864 }
865
866 module CatchPinProfileDemo(){ /////toplevel
867   translate([0, 0 * -bayo_behind,0]) {
868     echo("G ",
869          bayo_n[0] - bayo_e[0]);
870     color("blue") translate([0,0,
871                              +1,
872                ]) {
873       CatchAssemblyCoreProfile();
874       CatchHeadProfile();
875     }
876     translate([0,0,10])
877       color("red")
878       CatchTipProfile(0);
879
880     polygon(bayo_polygon, convexity=10);
881
882     // adhoc show a position
883     color("purple")
884     translate(concat(
885                      cppa,
886                      10
887                      )) difference(){ circle(2.5); circle(2.0); }
888
889  }
890 }
891
892 //ProfilesDemo();
893 //BayonetCutout();
894 //MainProfile();
895 //Cover();
896 //Jig();
897 //CoverTest();