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