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