chiark / gitweb /
lock-inframe-bracket: MainPositive seem ok
[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 // calculated
21
22 front_th = main_th;
23
24 tube_or = tube_dia/2 + main_th;
25 back_ohw = back_gap/2 + main_th;
26 backflange_ymin = tube_or+backflange_d;
27
28 lock_0y = tube_dia/2 + lock_d/2 + midweb_d;
29
30 lock_or = [lock_w, lock_d]/2 + [front_th,front_th];
31
32 module oval(sz){ // sz[0] > sz[1]
33   xr = sz[0];
34   yr = sz[1];
35   hull(){
36     for (sx=[-1,+1]) {
37       translate([sx * (xr-yr), 0])
38         circle(r=yr);
39     }
40   }
41 }
42
43 module MainPlan(){
44   difference(){
45     union(){
46       circle(r = tube_or);
47       translate([-back_ohw,0]) mirror([0,1])
48         square([back_ohw*2, backflange_ymin]);
49     }
50     circle(r = tube_dia/2);
51     translate([-back_gap/2,1]) mirror([0,1])
52       square([back_gap, backflange_ymin+2]);
53   }
54   translate([0, lock_0y]){
55     difference(){
56       union(){
57         oval(lock_or);
58       }
59       oval([lock_w/2, lock_d/2]);
60     }
61   }
62 }
63
64 lockshaft_or = lockshaft_r + [clip_th,clip_th];
65 cliprecess_ymax = cliprecess_h - lockshaft_r[1];
66 clip_ymin = cliprecess_ymax - total_h;
67 clip_ogap = clip_gap + clip_th*2;
68
69 module ClipElevationPositive(){
70   oval(lockshaft_or);
71   translate([-lockshaft_or[0], 0])
72     square([lockshaft_or[0]*2, cliprecess_ymax]);
73   translate([-clip_ogap/2, 0]) mirror([0,1]) square([clip_ogap, -clip_ymin]);
74 }
75
76 module ClipElevationNegative(){
77   hull(){
78     for (y=[0, cliprecess_ymax+1])
79       translate([0, y])
80         oval(lockshaft_r);
81   }
82   translate([-clip_gap/2, 1]) mirror([0,1]) square([clip_gap, 2-clip_ymin]);
83 }
84
85 module ClipElevation(){
86   difference(){
87     ClipElevationPositive(1);
88     ClipElevationNegative(0);
89   }
90 }
91
92 module ExtrudeClipElevation(extra=0){
93   translate([0,
94              lock_0y + lock_d/2 + clip_d + extra,
95              -clip_ymin])
96     rotate([90,0,0])
97     linear_extrude(height= clip_d + extra*2, convexity=100)
98     children(0);
99 }
100
101 module MainPositive(){
102   difference(){
103     union(){
104       linear_extrude(height=total_h, convexity=100) MainPlan();
105       ExtrudeClipElevation() ClipElevationPositive();
106     }
107     ExtrudeClipElevation(1) ClipElevationNegative();
108   }
109 }
110
111 //MainPlan();
112 //ClipElevation();
113 MainPositive();