Repository navigation
Expand file tree
/
Copy pathlib_boxes5.scad
More file actions
164 lines (154 loc) · 2.75 KB
/
Copy pathlib_boxes5.scad
File metadata and controls
164 lines (154 loc) · 2.75 KB
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
// boxes5.scad
/**
x1 = width
y1 = depth
z1 = height
r1 = radius of corners
*/
module rounded_rectangle(x1, y1, z1, r1) {
if (r1 > 0.00001) { // deal with rounding errors
translate([r1, r1, 0]) {
minkowski () {
cube([x1-2*r1, y1-2*r1, z1/2]);
cylinder(z1/2, r1, r1);
}
}
} else {
cube([x1, y1, z1]);
}
}
/**
x1 = width
y1 = depth
z1 = height
r1 = radius of corners
d1 = thickness
*/
module rounded_ring(x1, y1, z1, r1, d1) {
difference () {
rounded_rectangle(x1, y1, z1, r1);
translate([d1, d1, 0]) {
rounded_rectangle(x1-2*d1, y1-2*d1, z1+0.001, r1-d1);
}
}
}
/**
x1 = width
y1 = depth
z1 = height
r1 = radius of corners
d1 = thickness
*/
module open_box(x1, y1, z1, r1, d1) {
rounded_rectangle(x1, y1, d1, r1);
rounded_ring(x1, y1, z1, r1, d1);
}
/**
Bottom of a friction fit box
x1 = width
y1 = depth
z1 = height
r1 = radius of corners
d1 = thickness
z2 = friction
d2 = tolerance
*/
module box_bottom(x1, y1, z1, r1, d1, z2, d2) {
x2 = d1/2+d2/2;
y2 = d1/2+d2/2;
x3 = x1-2*x2;
y3 = y1-2*y2;
r3 = max(r1-x2, 0);
d3 = d1/2-d2/2;
mm = floor(min(x1, y1)/10);
difference() {
union() {
open_box(x1, y1, z1-z2, r1, d1);
translate([x2, y2, 0]) {
rounded_ring(x3, y3, z1-d2, r3, d3);
}
}
*for (ii = [1 : mm]) {
xx1 = 5*ii;
xx2 = x1-10*ii;
yy1 = 5*ii;
yy2 = y1-10*ii;
rr2 = r1-5*ii;
translate([xx1, yy1, 0]) {
rounded_ring(xx2, yy2, 0.65, rr2, 3);
}
}
}
}
/**
Top of a friction fit box.
x1 = width
y1 = depth
z1 = height
r1 = radius of corners
d1 = thickness
z2 = friction
d2 = tolerance
*/
module box_top(x1, y1, z1, r1, d1, z2, d2) {
x2 = d1/2+d2;
y2 = d1/2+d2;
x3 = x1-2*x2;
y3 = y1-2*y2;
z3 = z1+z2-d2;
r3 = max(r1-x2, 0);
d3 = d1/2-d2/2;
mm = floor(min(x1, y1)/10);
difference() {
union() {
open_box(x1, y1, z1-z2, r1, d1);
rounded_ring(x1, y1, z1-d2, r1, d3);
}
*for (ii = [1 : mm]) {
xx1 = 5*ii;
xx2 = x1-10*ii;
yy1 = 5*ii;
yy2 = y1-10*ii;
rr2 = r1-5*ii;
translate([xx1, yy1, 0]) {
rounded_ring(xx2, yy2, 0.65, rr2, 3);
}
}
}
}
/**
x1 = width
y1 = depth
z1 = height
r1 = radius of corners
d1 = thickness
z2 = friction
d2 = tolerance
r2 = radius of fingers
*/
module fingers(x1, y1, z1, r1, d1, z2, d2, r2) {
zz = max(z1, r2+d2);
translate([0, y1/2, zz]) {
rotate([0, 90, 0]) {
translate([0, 0, -1]) {
cylinder(x1+2, r2, r2);
}
}
}
}
/**
x1 = width
y1 = depth
z1 = height
d1 = thickness
z2 = friction
d2 = tolerance
*/
module pimples(x1, y1, z1, d1, z2, d2) {
translate([x1/2, (d1/2), z1-(z2/2)]) {
sphere(d1/2);
}
translate([x1/2, y1-(d1/2), z1-(z2/2)]) {
sphere(d1/2);
}
}