-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmicrocassette-case.scad
246 lines (209 loc) · 6.43 KB
/
microcassette-case.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
// Dimensions of the cavity for the cassette.
// Note that thickness must be adjusted depending on how good the printer's bridges are.
interior_dimensions = [51, 35, 8.8];
// X and Y offset of one reel's center from the center of the cavity.
reel_position = [10.5, -1.5];
// Diameter of the pin that locks the reels from turning.
reel_pin_diameter = 8;
pocket_depth = 12;
wall_thickness = 1;
cover_gap = 0.3;
hinge_plate_gap = 0.2;
hinge_diameter = 3;
hinge_nub_thickness = 1.0;
latch_diameter = 2;
latch_nub_thickness = 0.65;
latch_preload_offset = 0.8;
outer_chamfer = 0.4;
epsilon = 0.1;
outsideplusexact = interior_dimensions + [1, 1, 1] * (wall_thickness * 2);
outsideplus = interior_dimensions + [1, 1, 1] * ((wall_thickness + epsilon) * 2);
outsideplushalf = outsideplus / 2;
hinge_plate_thickness = wall_thickness;
full_outside_dimensions = interior_dimensions + [
wall_thickness + hinge_plate_thickness + hinge_plate_gap,
wall_thickness,
wall_thickness] * 2;
hinge_position = [
0, // must be 0, symmetric about x axis
interior_dimensions.y / 2 - interior_dimensions.z * 0.3, // TODO: calculate this based on the pocket_depth
0
];
printable();
module printable() {
separation = full_outside_dimensions.x + 1;
translate([-separation / 2, 0, 0])
base_half();
translate([separation / 2, 0, 0])
rotate([180, 0, 0])
cover_half();
}
module preview() {
color("pink") base_half();
%cover_half();
}
module hinge_preview() {
for (i = [0:6]) {
angle = i * 10;
translate([0, 0, (full_outside_dimensions.z + 5) * i + full_outside_dimensions.y * sin(angle)])
hinge_preview_1(angle);
}
for (i = [7:9]) {
angle = i * 10;
translate([0, 10 + full_outside_dimensions.y, (full_outside_dimensions.y + 5) * (i - 7)])
hinge_preview_1(angle);
}
}
module hinge_preview_1(angle) {
difference() {
color("pink") base_half();
cut();
}
translate(hinge_position)
rotate([-angle, 0, 0])
translate(-hinge_position)
difference() {
cover_half();
cut();
}
module cut() {
translate([full_outside_dimensions.x * 0.2, 0, 0])
cube(full_outside_dimensions * 1.2, center=true);
}
}
module base_half() {
intersection() {
difference() {
shell(false);
cut(false);
hinge_axis() cylinder(d=hinge_diameter, h=outsideplus.x, center=true, $fn=30);
latch_axis() cylinder(d=latch_diameter, h=outsideplus.x, center=true, $fn=30);
}
outside_chamfer_shape();
}
}
module cover_half() {
render(convexity=4) { // cheap and improves glitches in preview
intersection() {
union() {
intersection() {
shell(true);
cut(true);
}
mirrored([1, 0, 0])
cover_end_plate();
}
outside_chamfer_shape();
}
}
// Reel locking pin
mirrored([1, 0, 0])
translate([reel_position.x, reel_position.y, interior_dimensions.z / 2])
mirror([0, 0, 1])
reel_pin();
}
module reel_pin() {
height = interior_dimensions.z - cover_gap;
thickness = 0.9;
for (i = [0:2]) {
rotate([0, 0, 30 + i * 120])
rotate([90, 0, 0])
linear_extrude(thickness, center=true, convexity=1)
polygon([
[0, 0],
[reel_pin_diameter / 2, 0],
[reel_pin_diameter / 2, height / 2],
[thickness, height],
[0, height],
]);
}
}
module cover_end_plate() {
translate([interior_dimensions.x / 2 + wall_thickness + hinge_plate_gap, 0, 0]) {
translate([hinge_plate_thickness / 2, 0, 0])
cube([hinge_plate_thickness, outsideplusexact.y, outsideplusexact.z], center=true);
hinge_axis() inward_nub(hinge_diameter + hinge_plate_gap, hinge_nub_thickness, 3);
translate([0, 0, latch_preload_offset])
latch_axis()
mirror([0, 0, 1]) cylinder(d1=latch_diameter, d2=0, h=latch_nub_thickness, $fn=30);
}
}
module inward_nub(d, h, bevel_slope) {
mirror([0, 0, 1]) // sticks out towards center
cylinder(d1=d, d2=max(0, d - 2 * h / bevel_slope), h=h, $fn=30);
}
module cut(is_for_cover) {
slant = interior_dimensions.z / 2; // TODO not accounting for thicknesses
translate(is_for_cover ? [0, -cover_gap / sqrt(2), cover_gap] : [0, 0, 0])
rotate([0, 90, 0])
mirror([1, 0, 0])
linear_extrude(interior_dimensions.x + 2 * (wall_thickness + hinge_plate_gap + epsilon), center=true)
polygon([
[-interior_dimensions.z/2, -outsideplushalf.y],
[-interior_dimensions.z/2, outsideplushalf.y - pocket_depth - slant],
[outsideplushalf.z, outsideplushalf.y - pocket_depth + slant],
[outsideplushalf.z, -outsideplushalf.y],
]);
}
module shell(is_for_cover) {
difference() {
minkowski() { // TODO this can be just a sized cube
cube([
(wall_thickness + (is_for_cover ? hinge_plate_gap + hinge_plate_thickness : 0)) * 2,
wall_thickness * 2,
wall_thickness * 2,
], center=true);
cube(interior_dimensions, center=true);
}
cube(interior_dimensions, center=true);
}
}
module outside_chamfer_shape() {
octabox(d=full_outside_dimensions, r=outer_chamfer);
}
module hinge_axis() {
translate(hinge_position)
rotate([0, 90, 0])
children();
}
module latch_axis() {
// TODO: y position is not correctly calculated vs. pocket depth
translate([
0,
interior_dimensions.y / 2 - pocket_depth,
-interior_dimensions.z / 2 + latch_diameter / 2])
rotate([0, 90, 0])
children();
}
module octabox(d, r, center=true) {
minkowski() {
cube(d - [1, 1, 1] * r * 2, center=center);
octahedron(r);
}
}
module octahedron(r) {
scale([r, r, r])
polyhedron(
points=[
[1, 0, 0],
[-1, 0, 0],
[0, 1, 0],
[0, -1, 0],
[0, 0, 1],
[0, 0, -1],
],
faces=[
[0, 4, 2],
[0, 2, 5],
[0, 3, 4],
[0, 5, 3],
[1, 2, 4],
[1, 5, 2],
[1, 4, 3],
[1, 3, 5],
], convexity=1);
}
module mirrored(axis) {
children();
mirror(axis) children();
}