-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomponent mount.scad
192 lines (173 loc) · 4.2 KB
/
component mount.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
include <../BH-Lib/all.scad>
module component_diff(
board_dim,
lip_thickness = 0.4,
) {
thickness = board_dim[2] + lip_thickness * 2;
translate([0, 0, thickness / 2])
reflect(x = false, y = false, z = true)
translate([0, 0, -0.01])
linear_extrude(max(board_dim[0], board_dim[1]) / 2, scale = 0)
// offset(delta = thickness / 2) {
offset(delta = board_dim[2] / 2 + TOLERANCE_CLOSE) {
if ($children > 0) {
children();
} else
sq([board_dim[0], board_dim[1]]);
}
}
module component_mount(
bevel = true,
board_dim,
board_offset = [0, 0],
cutouts = [0, 0],
h,
hole_offset = [0, 0],
hole_spacing = [20, 20],
lip_thickness = 0.4,
screws = [true, true],
screw_r,
screw_surround = 1.5,
surround = 1.5,
) {
thickness = board_dim[2] + lip_thickness * 2;
height = max(h ? h : 0, thickness);
difference() {
union() {
difference() {
union() {
// outer
linear_extrude(thickness, convexity = 2)
smooth_acute(thickness * 0.4) {
// surround
difference() {
translate(board_offset)
shape_component_surround(board_dim, surround) {
if ($children > 0)
children();
else
sq([board_dim[0], board_dim[1]]);
}
if (cutouts[0]) {
reflect(x = cutouts[0], y = false)
translate([board_dim[0] / 2, 0])
// sq([board_dim[0], hole_spacing[1] - (screw_r + screw_surround) * 2]);
sq([board_dim[0], board_dim[1] * 0.9]);
}
if (cutouts[1]) {
reflect(x = false, y = cutouts[1])
translate([0, board_dim[1] / 2])
sq([hole_spacing[0] - (screw_r + screw_surround) * 2, board_dim[1]]);
}
}
// screw surrounds
if (screw_r)
reflect(x = screws[0], y = screws[1])
shape_component_mount_screw_surround(
hole_offset = hole_offset,
hole_spacing = hole_spacing,
screw_r = screw_r,
screw_surround = screw_surround);
}
// posts
if (height > thickness)
reflect(x = screws[0], y = screws[1])
component_post(
bevel = bevel,
h = height,
hole_offset = hole_offset,
hole_spacing = hole_spacing,
screw_surround = screw_surround,
screw_r = screw_r);
}
// cutout
translate(board_offset)
component_diff(board_dim, lip_thickness) {
if ($children > 0)
children();
else
sq([board_dim[0], board_dim[1]]);
}
}
}
// screw holes
if (screw_r)
reflect(x = screws[0], y = screws[1])
component_post_hole(
h = height,
hole_offset = hole_offset,
hole_spacing = hole_spacing,
screw_r = screw_r);
}
}
module component_post(
bevel = true,
h,
hole_offset = [0, 0],
hole_spacing = [20, 20],
screw_surround = 1.5,
screw_r,
) {
translate(hole_offset)
translate(hole_spacing / 2) {
cylinder_true(h = h - screw_surround, r = screw_r + screw_surround, center = false);
// bevel end of post
translate([0, 0, h - screw_surround])
cylinder_true(
h = screw_surround,
r1 = screw_r + screw_surround,
r2 = screw_r + (bevel ? PRINT_NOZZLE_DIA : screw_surround), center = false);
}
}
module component_post_hole(
h,
hole_offset = [0, 0],
hole_spacing = [20, 20],
screw_r,
terminal = false // doesn't use true radius hole when terminal (for tightness)
) {
translate(hole_offset)
translate(hole_spacing / 2)
translate([0, 0, -0.1]) {
if (terminal)
cylinder(h = h + 0.2, r = screw_r);
else
cylinder_true(h = h + 0.2, r = screw_r, center = false);
}
}
module component_surround(
board_dim,
lip_thickness = 0.4,
surround = 1.5,
) {
thickness = board_dim[2] + lip_thickness * 2;
linear_extrude(thickness, convexity = 2)
smooth_acute(thickness / 2)
shape_component_surround(board_dim, surround) {
if ($children > 0)
children();
else
sq([board_dim[0], board_dim[1]]);
}
}
module shape_component_surround(
board_dim,
surround = 1.5,
) {
offset(r = TOLERANCE_FIT + surround) {
if ($children > 0)
children();
else
sq([board_dim[0], board_dim[1]]);
}
}
module shape_component_mount_screw_surround(
hole_offset = [0, 0],
hole_spacing = [20, 20],
screw_r,
screw_surround = 1.5,
) {
translate(hole_offset)
translate(hole_spacing / 2)
circle_true(screw_r + screw_surround);
}