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