-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpixie-clock-enclosure.scad
169 lines (122 loc) · 3.5 KB
/
pixie-clock-enclosure.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
/*[Dimensions]*/
// Width of the case in mm (interior dimension)
interiorWidth = 69.85;
// Length of the case in mm (interior dimension)
interiorLength = 139.7;
// Height of the case in mm (interior dimension)
interiorHeight = 25.4;
// Case interior fillet radius
interiorFillet = 0;
// Width of the hinge in mm
hingeWidth = 0;
/*[Walls]*/
// Horizontal wall (top and bottom) thickness
coverThickness = 5.0;
// Vertical wall (side) thickness
sidewallWidth = 5.1;
// Amount the lid protrudes into the case (larger value allows the case to close more securely)
lidInsetHeight = 0;
// Thickness of the hinge (it should be no more than a few layers thick keep it flexible)
hingeThickness = 0;
// hinge length multiplier (as a function of case height - longer hinges may be needed for less flexible plastics)
hingeLengthScale = 8;
/*[Details]*/
// Distance the top and bottom surfaces extend beyond the sides of the case (makes the case easier to open)
rimInset = 0.0;
// Length of the opening tab on the lid of the case (optional - set to 0 to remove)
tabSize = 0;
// Fillet radius used for hinge and tab
hingeFillet = 3;
/*[Printer Tolerances]*/
// Adjust the tightness of the closed case (larger value makes the case looser, negative value makes it tighter - try adjusting in 0.1mm increments)
lidInsetOffset = 0.0;
/*[hidden]*/
eps = 0.1;
$fn = 120; // resolution
module case()
{
// minimal error checking
baseLength = interiorLength + sidewallWidth*2;
baseWidth = interiorWidth + sidewallWidth*2;
baseRadius = interiorFillet + sidewallWidth;
caseLength = baseLength + rimInset*2;
caseWidth = baseWidth + rimInset*2;
caseRadius = baseRadius + rimInset;
hingeLength = hingeLengthScale * interiorHeight + coverThickness*2;
centerY = (caseLength + hingeLength)/2;
filletXOffset = hingeWidth/2 + hingeFillet;
filletYOffset = hingeLength/2 - hingeFillet;
module rrect(h, w, l, r) {
r = min(r, min(w/2, l/2));
w = max(w, eps);
l = max(l, eps);
h = max(h, eps);
if (r <= 0) {
translate([-w/2, -l/2,0]) {
cube([w,l,h]);
}
} else {
hull() {
for (y = [-l/2+r, l/2-r]) {
for (x = [-w/2+r, w/2-r]) {
translate([x,y,0]) {
cylinder(h=h, r=r, center=false
);
}
}
}
}
}
}
module rrectTube(h, ow, ol, or, t) {
difference() {
rrect(h=h, w=ow, l=ol, r=or);
translate([0,0,-eps]) {
rrect(h=h+eps*2, w=ow-t*2, l=ol-t*2, r=or-t);
}
}
}
union() {
// bottom surfaces
for (i = [-centerY, centerY]) {
translate([0,i,0]) {
rrect(h=coverThickness, w=caseWidth, l=caseLength, r=caseRadius);
}
}
translate([0,0,coverThickness-eps]) {
// base
translate([0,centerY,0]) {
rrectTube(h=interiorHeight+eps, ow=baseWidth, ol=baseLength, or=baseRadius, t=sidewallWidth);
}
// lid
{
}
}
// hinge
if (hingeWidth > caseWidth - caseRadius*2) {
translate([-hingeWidth/2,-centerY,0]) {
cube([hingeWidth, centerY*2, hingeThickness]);
}
} else {
difference() {
translate([-hingeWidth/2 - hingeFillet,-centerY,0]) {
cube([hingeWidth + hingeFillet*2, centerY*2, hingeThickness]);
}
}
}
// tab
if (tabSize > 0) {
hull() {
for (x = [hingeFillet - hingeWidth/2, hingeWidth/2 - hingeFillet]) {
translate([x,-caseLength - hingeLength/2 - tabSize + hingeFillet,0]) {
cylinder(h=coverThickness, r=hingeFillet, center=false);
}
}
translate([-hingeWidth/2,-centerY,0]) {
cube([hingeWidth, eps, coverThickness]);
}
}
}
}
}
case();