]> www.fi.muni.cz Git - things.git/blob - vesak-filip-aktovka.scad
switch holder.scad
[things.git] / vesak-filip-aktovka.scad
1 include <yenyalib.scad>;
2
3 eps = 0.01;
4 infty = 200;
5
6 thin_version = 0;
7 wall = 8;
8
9 inner_w = 82;
10 outer_w = inner_w + 2*30;
11 inner_w_round_r = 2;
12 body_h = thin_version ? 8 : 30;
13 bottom_w = thin_version ? 35 : 70;
14
15 top_w = bottom_w + 3*wall;
16 bottom_h = 60;
17
18 module top_part() {
19         difference() {
20                 round_with() {
21                         rounding();
22                         hull() {
23                                 Mx()
24                                 Tx(outer_w/2 - 4*wall)
25                                 Sx(2)
26                                         cylinder(r = 2*wall, h = body_h);
27                         }
28                 }
29                 translate([-outer_w/2-eps, -2*wall-eps, -eps])
30                         cube([outer_w + 2*eps, 2*wall-inner_w_round_r,
31                                 body_h + 2*eps]);
32                 Mx() translate([inner_w/2 + inner_w_round_r,
33                         -inner_w_round_r, -eps]) hull() {
34                         cylinder(r = inner_w_round_r, h = body_h + 2*eps);
35                         cube([inner_w/2, inner_w_round_r, body_h + 2*eps]);
36                 }
37         }
38 }
39
40 hole_d = thin_version ? 20 : 35;
41 hole_l = 1.25*hole_d;
42 hole_xoff = 0.2*(bottom_w-hole_d);
43 hole_yoff = bottom_h - 0.2*hole_d;
44 hole_top_yoff = 7;
45 hole_top_l = thin_version ? 30 : 20;
46 hook_top_rx = thin_version ? 4 : 8;
47 hook_top_ry = thin_version ? 6 : 12;
48 module bottom_part() {
49         difference() {
50                 hull() {
51                         Tx(-inner_w/2) Ty(-inner_w_round_r)
52                                 cube([inner_w, wall/2, body_h]);
53                         Ty(-bottom_h) cylinder(r = bottom_w/2, h = body_h);
54                 }
55                 // main hole
56                 difference() {
57                         hull() {
58                                 translate([hole_xoff, -hole_yoff, -eps])
59                                         cylinder(r = hole_d/2, h = body_h+2*eps);
60                                 translate([hole_xoff,
61                                         -hole_yoff-hole_d+hole_l, -eps])
62                                         cylinder(r = hole_d/2, h = body_h+2*eps);
63                         }
64                         // rounded hook inner bottom
65                         translate([-inner_w/2, -hole_yoff-hole_d/2, body_h/2])
66                         Sy(0.7)
67                         Ry(90)
68                                 cylinder(r = 0.55*body_h, h = inner_w);
69                 }
70                 // cut to the top
71                 hull() {
72                         translate([inner_w/2+inner_w_round_r,
73                                 -hole_top_l-hole_top_yoff, -eps])
74                                 cube([eps, hole_top_l, body_h+2*eps]);
75                         translate([hole_xoff, -hole_yoff-hole_d+hole_l, -eps])
76                                 intersection() {
77                                         cylinder(r = hole_d/2, h = body_h+2*eps);
78                                         translate([-infty, 0, -infty/2])
79                                                 cube(infty);
80                                 }
81                 }
82                 // rounded hook end
83                 difference() {
84                         translate([hole_xoff, -hole_yoff, -eps])
85                                 cube([inner_w/2, hole_l-hole_d/2, body_h+2*eps]);
86                         translate([hole_xoff + hole_d/2 + hook_top_rx - 2*eps,
87                                 -hole_yoff, -2*eps])
88                                 Sy(hook_top_ry/hook_top_rx)
89                                 cylinder(r = hook_top_rx, h = body_h + 4*eps);
90                 }
91         }
92 }
93
94 module rounding() {
95         if (thin_version) {
96                 Mz() cylinder(r1 = 2, r2 = 0, h = 3, $fn = 8);
97         } else {
98                 Mz() cylinder(r1 = 3, r2 = 0, h = 4.5, $fn = 8);
99         }
100 }
101         
102
103 $fn = 128;
104 top_part();
105
106 // pro prichyceni ABS, ale stejne nefunguje
107 // Mx() Tx(outer_w/2-3) Ty(3)
108 //      cylinder(r = 15, h = 0.4);
109
110 round_with() {
111         rounding();
112         bottom_part();
113 }
114
115
116 /*
117 // rotate_extrude(angle=360, convexity=10) {
118
119 outer_d = 1.1*body_h;
120 inner_d = body_h - 1.7*wall;
121 inner_scale = 1.5;
122 hole_depth = 0.01*bottom_h;
123 difference() {
124         difference() {
125                 union() {
126                         Ty(outer_d/2-eps) square([body_h, bottom_h - outer_d/2 + eps]);
127                         intersection() {
128                                 square(body_h);
129                                 Tx(body_h/2) Ty(outer_d/2)
130                                         circle(r = outer_d/2);
131                         }
132                 }
133                 hull() {
134                         Tx(body_h) Ty(bottom_h-hole_depth)
135                                 square([eps, hole_depth]);
136                         Tx(wall + inner_d/2) Ty(wall + inner_scale*inner_d/2)
137                                 Sy(inner_scale)
138                                 circle(r = inner_d/2);
139                         Tx(wall + inner_d/2) Ty(wall + inner_d/2)
140                                 circle(r = inner_d/2);
141                 }
142         }
143 }
144 */
145