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