chiark / gitweb /
lock-inframe-bracket: ThroughHoles wip
[reprap-play.git] / lock-inframe-bracket.scad
1 // -*- C -*-
2
3 tube_dia = 27.5 + 0.5;
4 lock_w = 42.5 + 0.5;
5 lock_d = 28.0 + 0.5;
6 main_h = 45.0;
7 backflange_d = 12;
8
9 lockshaft_r = [5, 5];
10 cliprecess_h = 16;
11 total_h = 45;
12
13 back_gap = 7;
14 main_th = 2.5;
15 midweb_d = 3;
16 clip_th = 2.5;
17 clip_gap = 2.5;
18 clip_d = 22.0;
19
20 mountscrew_dia = 4 + 0.5;
21 clipbolt_dia = 5 + 0.5;
22
23 // calculated
24
25 front_th = main_th;
26
27 tube_or = tube_dia/2 + main_th;
28 back_ohw = back_gap/2 + main_th;
29 backflange_ymin = tube_or+backflange_d;
30
31 lock_0y = tube_dia/2 + lock_d/2 + midweb_d;
32
33 lock_or = [lock_w, lock_d]/2 + [front_th,front_th];
34
35 module oval(sz){ // sz[0] > sz[1]
36   xr = sz[0];
37   yr = sz[1];
38   hull(){
39     for (sx=[-1,+1]) {
40       translate([sx * (xr-yr), 0])
41         circle(r=yr);
42     }
43   }
44 }
45
46 module MainPlan(){
47   difference(){
48     union(){
49       circle(r = tube_or);
50       translate([-back_ohw,0]) mirror([0,1])
51         square([back_ohw*2, backflange_ymin]);
52     }
53     circle(r = tube_dia/2);
54     translate([-back_gap/2,1]) mirror([0,1])
55       square([back_gap, backflange_ymin+2]);
56   }
57   translate([0, lock_0y]){
58     difference(){
59       union(){
60         oval(lock_or);
61       }
62       oval([lock_w/2, lock_d/2]);
63     }
64   }
65 }
66
67 lockshaft_or = lockshaft_r + [clip_th,clip_th];
68 cliprecess_ymax = cliprecess_h - lockshaft_r[1];
69 clip_ymin = cliprecess_ymax - total_h;
70 clip_ogap = clip_gap + clip_th*2;
71
72 module ClipElevationPositive(){
73   oval(lockshaft_or);
74   translate([-lockshaft_or[0], 0])
75     square([lockshaft_or[0]*2, cliprecess_ymax]);
76   translate([-clip_ogap/2, 0]) mirror([0,1]) square([clip_ogap, -clip_ymin]);
77 }
78
79 module ClipElevationNegative(){
80   hull(){
81     for (y=[0, cliprecess_ymax+1])
82       translate([0, y])
83         oval(lockshaft_r);
84   }
85   translate([-clip_gap/2, 1]) mirror([0,1]) square([clip_gap, 2-clip_ymin]);
86 }
87
88 module ClipElevation(){
89   difference(){
90     ClipElevationPositive(1);
91     ClipElevationNegative(0);
92   }
93 }
94
95 module ExtrudeClipElevation(extra=0){
96   translate([0,
97              lock_0y + lock_d/2 + clip_d + extra,
98              -clip_ymin])
99     rotate([90,0,0])
100     linear_extrude(height= clip_d + extra*2, convexity=100)
101     children(0);
102 }
103
104 module ThroughHole(r, y, z) {
105   translate([-50, y, z])
106     rotate([0, 90, 0])
107     cylinder(r=r, h=100, $fn=20);
108 }
109
110 module ThroughHoles(){
111   for (z=[ 1/4, 3/4 ]) {
112     ThroughHole( mountscrew_dia/2,
113                  -tube_or -0.5*backflange_d,
114                  total_h * z );
115   }
116
117   ThroughHole( clipbolt_dia/2,
118                lock_0y + lock_d/2 + clip_d/2,
119                total_h - cliprecess_h - clip_th - clip_d/2 );
120 }
121
122 module MainPositive(){
123   difference(){
124     union(){
125       linear_extrude(height=total_h, convexity=100) MainPlan();
126       ExtrudeClipElevation() ClipElevationPositive();
127     }
128     ExtrudeClipElevation(1) ClipElevationNegative();
129   }
130 }
131
132 //MainPlan();
133 //ClipElevation();
134 MainPositive();
135 %ThroughHoles();