-
Notifications
You must be signed in to change notification settings - Fork 0
/
pad.scad
151 lines (133 loc) · 2.65 KB
/
pad.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
// door lock pad
$fn = 60;
x = 61.0; // plate dimension in X (width)
y = 28.0; // plate dimension in 4 (height)
z = 12.0; // plate dimension in Z (thickness) -- door to outside
r = 1.5; // radius of corners
hx = 11.0; // hole X
hy = 15.0; // hole Y
hd = 4.5; // hole diameter
hh = 80.0; // hole "height"
chx = x/2.0;// center hole X
chy = 8.0; // center hole X
chd = hd; // center hole diameter
chh = hh; // center hole "height"
csd = 5.5; // counter-sunk diameter
csh = 1.0; // counter-sunk height
module roundedBox0(
size = [1, 1, 1],
radius = 0.1,
sidesOnly = false
) {
hull() {
for(z = [-size[2]/2, size[2]/2]) {
for(y = [-size[1]/2, size[1]/2]) {
for(x = [-size[0]/2, size[0]/2]) {
translate([
x - radius*sign(x),
y - radius*sign(y),
z - radius*sign(z)
])
if(sidesOnly) {
cylinder(
r = radius,
h = 2*radius,
center=true
);
} else {
sphere(
r = radius,
center=true
);
}
}
}
}
}
}
module roundedBox(
size = [1, 1, 1],
radius = 0.1,
sidesOnly = false,
topOnly = false
) {
if(false==topOnly) {
roundedBox0(
size = size,
radius = radius,
sidesOnly = sidesOnly
);
} else {
translate([0, 0, -size[2]/2])
difference() {
roundedBox0(
size = [
size[0],
size[1],
2*size[2]
],
radius = radius,
sidesOnly = sidesOnly
);
scale([4*size[0], 4*size[1], 4*size[2]])
translate([-0.5, -0.5, -1])
cube();
}
}
}
// base rounded box shape
module box() {
translate([x/2.0, y/2.0, z/2.0])
roundedBox(
size = [x, y, z],
radius = r,
sidesOnly = true,
topOnly = true
);
}
// hole with a scaling factor
module hole(
s = 1.0
) {
translate([hx, hy, 0])
scale([s, s, 1.0])
cylinder(
d = hd,
h = hh,
center = true
);
}
// simple hole in the center
module centerHole() {
translate([chx, chy,0])
cylinder(
d = chd,
h = chh,
center = true
);
}
// side holes
module holes(
s = 1.0
) {
hole(s = s);
translate([x-hx-hx, 0, 0]) hole(s = s);
}
// counter-sunk around side holes
module counterSunkHole() {
translate([0, 0, csh/2.0])
scale([1, 1, csh/hh])
holes(s = (csd/hd));
}
module boredBox() {
difference() {
union() {
box();
translate([0, 0, -csh + 1/100]) counterSunkHole();
}
translate([0, 0, z-csh + 1/100]) counterSunkHole();
centerHole();
holes();
}
}
boredBox();