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