-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinsert.scad
More file actions
224 lines (192 loc) · 7.34 KB
/
Copy pathinsert.scad
File metadata and controls
224 lines (192 loc) · 7.34 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
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
// Customizable Ultimate Drawer System Inserts
// Remixed from MarcElbichon's Ultimate Drawer System https://www.thingiverse.com/thing:2302575 (CC-BY 4.0)
// Copyright (C) 2019 by Brian Alano (and possibly others)
// Licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 (CC-BY-NC-SA 4.0)
/* Design notes
// width is x dimension, across the face of the drawer
// depth is y dimension, front to back of the drawer
// height is z dimension
*/
/* Coding Style Guide
* User parameters and modules use underscores between words.
* Other variable names use camel case.
* Separate features into their own modules if they are more than a couple lines long.
* All dimensions should be assigned to variables, usually global ones so they can be found easily.
* Keep local modules local.
* Keep local variables local.
* Maintain Thingiverse Customizer compatibility.
* Maintain backwards compatibility with MarcElbichon's Ultimate Drawer System
(https://www.thingiverse.com/thing:2302575). This means a 1Ux1Ux1U drawer
made with this program will work in MarcElbichon's shelf.
See README.md for more.
*/
/* [Size] */
// Outside width in mm (1U drawer is 118 mm inside, 1.5U is 182.5 mm, 2U is 249 mm). Walls are 1 mm thick.
Width=59; // [8:0.1:249]
// Outside depth in mm (1U drawer is 118 mm inside, 1.5U is 182 mm, 2U is 248 mm). Walls are 1 mm thick.
Depth=59; // [8:0.1:248]
// Outside height in mm (1U drawer is 18 mm inside, 2U is 38 mm, 3U is 58 mm, etc.)
Height= 18; // [8:398]
// This amount is subtracted from each of the six sides to provide some wiggle room. Half your nozzle diameter is a safe place to start if you're not sure.
Tolerance=0.2; // [0.00:0.02:1.00]
// Don't print the bottom, just the perinimeter
Bottomless="no"; //[yes, no]
/* [Island] */
Island_Shape="none"; //[none,round,square]
// Size of center insert-within-insert. Must be smaller than depth
Island = 27;
Island_Offset = 0;
/* [Chevron] */
// Set the outside width of a divider in the shape of an inverted "V". 0 to disable.
Chevron_Width=0;
// Set the outside height of a divider in the shape of an inverted "V"
Chevron_Height=0;
// Distance above center. Negative to go below
Chevron_Offset=0;
/* [Hidden] */
drawerWallThickness = 1; // assumed
drawerCornerRadius = 4; // assumed
insertWallThickness = 1;
insertCornerRadius = drawerCornerRadius;
insertSize = [Width - Tolerance*2, Depth - Tolerance*2, Height - Tolerance*2];
X=[1, 0, 0];
Y=[0, 1, 0];
Z=[0, 0, 1];
// utility variables
epsilon = 0.01;
$fa=4;
$fs=0.5;
module double_fillet_profile(thickness, r) {
module add() {
translate([0, +r/2]) square([thickness+2*r, r], center=true);
}
module subtract() {
reflect(X) translate([r+thickness/2, r]) circle(r);
}
difference() {
add();
subtract();
}
}
module insert(size) {
module add() {
// main body
translate([0, 0, insertCornerRadius])
linear_extrude(size.z - insertCornerRadius)
roundtangle([size.x, size.y], radius=insertCornerRadius);
// filleted bottom
translate([0, 0, insertCornerRadius])
roundtangle3d([size.x, size.y], insertCornerRadius);
}
module subtract() {
insideRadius = insertCornerRadius - insertWallThickness;
// main cut, minus fillets
cut = [size.x - insertWallThickness*2,
size.y - insertWallThickness*2,
size.z - insertWallThickness];
bottomCut = [size.x - insertCornerRadius*2, size.y - insertCornerRadius*2, insertWallThickness + epsilon*2];
translate([0, 0, insideRadius + insertWallThickness - epsilon])
linear_extrude(cut.z - insideRadius + epsilon * 2)
roundtangle([cut.x, cut.y], insideRadius );
// fillet cut
translate([0, 0, insideRadius + insertWallThickness])
roundtangle3d([cut.x, cut.y], insideRadius);
if (Bottomless=="yes") {
translate([0, 0, bottomCut.z/2 - epsilon]) cube(bottomCut, center=true);
}
}
difference() {
add();
subtract();
}
}
module island(size) {
maxSize=min(size, Depth-insertCornerRadius*2-insertWallThickness);
island=[maxSize*Width/Depth, maxSize];
module side() {
side=[island.x-insertCornerRadius*2, island.y-insertCornerRadius*2];
reflect(X)
translate([(island.x-insertWallThickness)/2, 0]) rotate(X*90)
linear_extrude(side.y, center=true)
double_fillet_profile(insertWallThickness, insertCornerRadius);
reflect(Y)
translate([0, (island.y-insertWallThickness)/2]) rotate([90, 0, 90])
linear_extrude(side.x, center=true)
double_fillet_profile(insertWallThickness, insertCornerRadius);
}
module round() {
scale([Width/Depth, 1])
rotate_extrude()
translate([(island.y-insertWallThickness)/2, 0])
double_fillet_profile(insertWallThickness, insertCornerRadius);
}
module add() {
// corners
reflect(X) reflect(Y)
translate([island.x/2 - insertCornerRadius, island.y/2 - insertCornerRadius])
rotate_extrude(angle=90)
intersection() {
translate([(insertCornerRadius-insertWallThickness/2), 0, 0]) double_fillet_profile(insertWallThickness, insertCornerRadius);
square(insertCornerRadius*2);
}
// sides
side();
}
translate([0, Island_Offset, insertWallThickness])
if (Island_Shape=="round") {
round();
} else {
add();
}
}
module chevron(width, height, offset) {
step=width/20;
yFactor= height/y(0);
// Height=19;
function y(x) = -(pow(x/(width/2)-0.5,2))+2.25;
module add() {
translate([0, offset]) for(x=[-width/2:step:0]) {
x0=x-step; // used to get angle0
y0=y(x0)*yFactor; // used to get angle0
y=y(x)*yFactor; // equation is normalized to -1<x<1, 0<y<1
x2=x+step;
y2=y(x2)*yFactor;
angle0=atan((y-y0)/(x-x0));
angle1=atan((y2-y)/(x2-x));
echo("x,y,x2,y2, angle", x, y, x2, y2,angle1);
hull()
{
translate([x, y, Height/4]) rotate([0, 0, 90+angle0]) cube([insertWallThickness, epsilon, Height/2], center=true); //double_fillet_profile();
translate([x2, y2, Height/4]) rotate([0, 0, 90+angle1]) cube([insertWallThickness, epsilon, Height/2], center=true);// double_fillet_profile();
}
}
}
reflect(X) intersection() {
add();
translate([-width/2, offset]) cube([width/2, height, Height]);
}
}
module reflect(vector) {
children();
mirror(vector) children();
}
module roundtangle(size, radius) {
minkowski() {
square([max(size.x - radius*2, epsilon), max(size.y - radius*2, epsilon)], center=true);
circle(r=radius);
}
}
module roundtangle3d(size, r) {
minkowski() {
cube([max(size.x - r*2, epsilon), max(size.y - r*2, epsilon), epsilon], center=true);
sphere(r=r );
}
}
//difference() {
union() {
insert(insertSize);
if (Island_Shape != "none") island(Island);
if (Chevron_Width != 0) chevron(Chevron_Width, Chevron_Height, Chevron_Offset);
}
// cube(100);
//}