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