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