chiark / gitweb /
lock-inframe-bracket: MainPlan: reorg to make cutouts common (nfc)
[reprap-play.git] / lock-inframe-bracket.scad
1 // -*- C -*-
2
3 tube_dia = 27.5 + 1.625;
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 = 14.35;
9
10 cliprecess_h = 16;
11 total_h = 45;
12
13 back_gap = 10;
14 main_th = 2.5;
15 tube_th = 2.25;
16
17 midweb_d = 3;
18 clip_th = 3.5;
19 clip_gap = 2.5;
20 clip_d = 22.0;
21
22 mountscrew_dia = 4 + 0.5;
23 clipbolt_dia = 5 + 0.1;
24
25 backflange_th = 3.5;
26
27 $fn=50;
28
29 // calculated
30
31 lockshaft_r = [1, 1] * lockshaft_dia / 2;
32 front_th = main_th;
33
34 tube_or = tube_dia/2 + tube_th;
35 back_ohw = back_gap/2 + backflange_th;
36 backflange_ymin = tube_or+backflange_d;
37
38 lock_0y = tube_dia/2 + lock_d/2 + midweb_d;
39
40 lock_or = [lock_w, lock_d]/2 + [front_th,front_th];
41
42 module oval(sz){ // sz[0] > sz[1]
43   xr = sz[0];
44   yr = sz[1];
45   hull(){
46     for (sx=[-1,+1]) {
47       translate([sx * (xr-yr), 0])
48         circle(r=yr);
49     }
50   }
51 }
52
53 module MainPlan(){
54   difference(){
55     union(){
56       circle(r = tube_or);
57       translate([-back_ohw,0]) mirror([0,1])
58         square([back_ohw*2, backflange_ymin]);
59
60       translate([0, lock_0y]){
61         oval(lock_or);
62       }
63     }
64
65     circle(r = tube_dia/2);
66     translate([-back_gap/2,1]) mirror([0,1])
67       square([back_gap, backflange_ymin+2]);
68
69     translate([0, lock_0y]){
70       oval([lock_w/2, lock_d/2]);
71     }
72   }
73 }
74
75 lockshaft_or = lockshaft_r + [clip_th,clip_th];
76 cliprecess_ymax = cliprecess_h - lockshaft_r[1];
77 clip_ymin = cliprecess_ymax - total_h;
78 clip_ogap = clip_gap + clip_th*2;
79
80 module ClipElevationPositive(){
81   hull(){
82     oval(lockshaft_or);
83     translate([0, -lockshaft_or[1] * sqrt(2)])
84       square(center=true, 0.5);
85   }
86   translate([-lockshaft_or[0], 0])
87     square([lockshaft_or[0]*2, cliprecess_ymax]);
88   translate([-clip_ogap/2, 0]) mirror([0,1]) square([clip_ogap, -clip_ymin]);
89 }
90
91 module ClipElevationNegative(){
92   hull(){
93     for (y=[0, cliprecess_ymax+1])
94       translate([0, y])
95         oval(lockshaft_r);
96   }
97   translate([-clip_gap/2, 1]) mirror([0,1]) square([clip_gap, 2-clip_ymin]);
98 }
99
100 module ClipElevation(){
101   difference(){
102     ClipElevationPositive(1);
103     ClipElevationNegative(0);
104   }
105 }
106
107 module ExtrudeClipElevation(extra=0){
108   translate([0,
109              lock_0y + lock_d/2 + clip_d + extra,
110              -clip_ymin])
111     rotate([90,0,0])
112     linear_extrude(height= clip_d + extra*2, convexity=100)
113     children(0);
114 }
115
116 module ThroughHole(r, y, z) {
117   translate([-50, y, z])
118     rotate([0, 90, 0])
119     cylinder(r=r, h=100, $fn=20);
120 }
121
122 module ThroughHoles(){
123   for (z=[ 1/4, 3/4 ]) {
124     ThroughHole( mountscrew_dia/2,
125                  -tube_or -0.5*backflange_d,
126                  total_h * z );
127   }
128
129   ThroughHole( clipbolt_dia/2,
130                lock_0y + lock_d/2 + clip_d/2 + front_th/2,
131                total_h - cliprecess_h - clip_th - clip_d/2 );
132 }
133
134 module MainPositive(){
135   difference(){
136     union(){
137       linear_extrude(height=total_h, convexity=100) MainPlan();
138       ExtrudeClipElevation() ClipElevationPositive();
139     }
140     ExtrudeClipElevation(1) ClipElevationNegative();
141   }
142 }
143
144 module Bracket(){ //// toplevel
145   difference(){
146     MainPositive();
147     ThroughHoles();
148   }
149 }
150
151 module TestTopEdge(){ //// toplevel
152   intersection(){
153     translate([0,0, -total_h])
154       translate([0,0, 4])
155       Bracket();
156     translate([-200,-200,0])
157       cube([400,400,100]);
158   }
159 }
160
161 module TestClipBoltHole(){ //// toplevel
162   intersection(){
163     union(){
164       translate([0, 0, -5])
165         Bracket();
166       translate([-4, lock_0y + lock_d/2 + 1, 0])
167         cube([8, 4, 1.5]);
168     }
169     translate([-200, lock_0y + lock_d/2 + 0.1])
170       cube([400, 400, total_h-20]);
171   }
172 }
173
174 //MainPlan();
175 //ClipElevationPositive();
176 //ClipElevation();
177 //MainPositive();
178 //%ThroughHoles();
179 //TestTopEdge();
180 //TestClipBoltHole();
181
182 //Bracket();