1 | /** |
---|
2 | * Gergoas Bass Box |
---|
3 | */ |
---|
4 | |
---|
5 | /*********************************************************/ |
---|
6 | /* Configuration */ |
---|
7 | /*********************************************************/ |
---|
8 | |
---|
9 | /* Width / Depth / Height */ |
---|
10 | |
---|
11 | bb_width = 100; |
---|
12 | bb_depth = 100; |
---|
13 | bb_height = 250; |
---|
14 | |
---|
15 | /* Material */ |
---|
16 | |
---|
17 | bb_board_diameter = 9; |
---|
18 | |
---|
19 | /* |
---|
20 | * Openings |
---|
21 | */ |
---|
22 | |
---|
23 | /* Middle (Horizontal) Board Position */ |
---|
24 | |
---|
25 | bb_mid_board_pos = 15; |
---|
26 | |
---|
27 | /* Speaker Opening */ |
---|
28 | |
---|
29 | bb_speaker_cutout_radius = 40; |
---|
30 | |
---|
31 | /* Air Intake Opening */ |
---|
32 | |
---|
33 | bb_intake_space = bb_depth/5; |
---|
34 | |
---|
35 | /* Connectors Opening */ |
---|
36 | |
---|
37 | bb_conn_cutout_radius = 13; |
---|
38 | |
---|
39 | /* Status LED Opening */ |
---|
40 | |
---|
41 | bb_led_cutout_radius = 10; |
---|
42 | |
---|
43 | /* |
---|
44 | * Part Colors (for debugging the model) |
---|
45 | */ |
---|
46 | |
---|
47 | color_blue = [0.5, 0.5, 1.0]; |
---|
48 | color_green = [0.5, 1.0, 0.7]; |
---|
49 | color_red = [1.0, 0.5, 0.7]; |
---|
50 | color_yellow = [1.0, 1.0, 0.5]; |
---|
51 | color_gray = "gray"; |
---|
52 | color_orange = "orange"; |
---|
53 | |
---|
54 | /* Color mapping to parts */ |
---|
55 | |
---|
56 | top_color = color_orange; |
---|
57 | middle_color = color_gray; |
---|
58 | bottom_color = color_blue; |
---|
59 | |
---|
60 | front_color = color_red; |
---|
61 | back_color = color_yellow; |
---|
62 | |
---|
63 | side_left_color = color_green; |
---|
64 | side_right_color = color_green; |
---|
65 | |
---|
66 | /*********************************************************/ |
---|
67 | /* View Options */ |
---|
68 | /*********************************************************/ |
---|
69 | |
---|
70 | /* |
---|
71 | * Control view to draw. |
---|
72 | * |
---|
73 | * Set to 0 for assembled view (default). |
---|
74 | * Set to 1 for machining view. |
---|
75 | */ |
---|
76 | |
---|
77 | layout_parts = 0; |
---|
78 | |
---|
79 | /* |
---|
80 | * Disable drawing of left and right sides of the box. |
---|
81 | * |
---|
82 | * Default 0, set to 1 to activate. |
---|
83 | * Only works when "layout_parts" is set to 0. |
---|
84 | */ |
---|
85 | |
---|
86 | hide_sides = 0; |
---|
87 | |
---|
88 | /* |
---|
89 | * Disable drawing top, middle and bottom boards. |
---|
90 | * |
---|
91 | * Default 0, set to 1 to activate. |
---|
92 | * Only works when "layout_parts" is set to 0. |
---|
93 | */ |
---|
94 | |
---|
95 | hide_horizontal_boards = 0; |
---|
96 | |
---|
97 | /*********************************************************/ |
---|
98 | /* 'Modules' */ |
---|
99 | /*********************************************************/ |
---|
100 | |
---|
101 | /*=======================================================*/ |
---|
102 | /* Horizontal Boards */ |
---|
103 | /*=======================================================*/ |
---|
104 | |
---|
105 | /*-------------------------------------------------------*/ |
---|
106 | /* Top Board */ |
---|
107 | /*-------------------------------------------------------*/ |
---|
108 | |
---|
109 | module bb_top(top_pos, top_size, top_color) |
---|
110 | { |
---|
111 | translate(top_pos) |
---|
112 | { |
---|
113 | difference() |
---|
114 | { |
---|
115 | color(top_color) cube(top_size); |
---|
116 | |
---|
117 | translate([bb_width/2, bb_width/2, -bb_board_diameter/2]) |
---|
118 | { |
---|
119 | cylinder(h=bb_board_diameter*2,r=bb_speaker_cutout_radius); |
---|
120 | } |
---|
121 | } |
---|
122 | } |
---|
123 | } |
---|
124 | |
---|
125 | /*-------------------------------------------------------*/ |
---|
126 | /* Middle Board */ |
---|
127 | /*-------------------------------------------------------*/ |
---|
128 | |
---|
129 | module bb_middle(middle_pos, middle_size, middle_color) |
---|
130 | { |
---|
131 | translate(middle_pos) |
---|
132 | { |
---|
133 | difference() |
---|
134 | { |
---|
135 | color(middle_color) cube(middle_size); |
---|
136 | |
---|
137 | translate([bb_width/2, bb_depth/2, bb_mid_board_pos-bb_board_diameter*2]) |
---|
138 | { |
---|
139 | cylinder(r=bb_led_cutout_radius, h=bb_board_diameter*2); |
---|
140 | } |
---|
141 | } |
---|
142 | } |
---|
143 | } |
---|
144 | |
---|
145 | /*-------------------------------------------------------*/ |
---|
146 | /* Bottom Board */ |
---|
147 | /*-------------------------------------------------------*/ |
---|
148 | |
---|
149 | module bb_bottom(bottom_pos, bottom_size, bottom_color) |
---|
150 | { |
---|
151 | translate(bottom_pos) { color(bottom_color) cube(bottom_size); } |
---|
152 | } |
---|
153 | |
---|
154 | /*=======================================================*/ |
---|
155 | /* Vertical Boards */ |
---|
156 | /*=======================================================*/ |
---|
157 | |
---|
158 | /*-------------------------------------------------------*/ |
---|
159 | /* Front Board */ |
---|
160 | /*-------------------------------------------------------*/ |
---|
161 | |
---|
162 | module bb_front(front_pos, front_size, front_color) |
---|
163 | { |
---|
164 | translate(front_pos) { color(front_color) cube(front_size); } |
---|
165 | } |
---|
166 | |
---|
167 | /*-------------------------------------------------------*/ |
---|
168 | /* Side Boards Left */ |
---|
169 | /*-------------------------------------------------------*/ |
---|
170 | |
---|
171 | module bb_part_board_left(side_left_pos, side_left_size, side_left_color) |
---|
172 | { |
---|
173 | translate(side_left_pos) { color(side_left_color) cube(side_left_size); } |
---|
174 | } |
---|
175 | |
---|
176 | /*-------------------------------------------------------*/ |
---|
177 | /* Side Boards Right */ |
---|
178 | /*-------------------------------------------------------*/ |
---|
179 | |
---|
180 | module bb_part_board_right(side_right_pos, side_right_size, side_right_color) |
---|
181 | { |
---|
182 | translate(side_right_pos) { color(side_right_color) cube(side_right_size); } |
---|
183 | } |
---|
184 | |
---|
185 | /*-------------------------------------------------------*/ |
---|
186 | /* Back Board */ |
---|
187 | /*-------------------------------------------------------*/ |
---|
188 | |
---|
189 | module bb_part_board_back(back_pos, back_size, back_color) |
---|
190 | { |
---|
191 | opening_offset = 60; |
---|
192 | opening_bottom = bb_conn_cutout_radius + opening_offset; |
---|
193 | opening_top = bb_conn_cutout_radius + opening_bottom; |
---|
194 | opening_height = opening_top - opening_bottom; |
---|
195 | |
---|
196 | translate(back_pos) |
---|
197 | { |
---|
198 | difference() |
---|
199 | { |
---|
200 | color(back_color) cube(back_size); |
---|
201 | |
---|
202 | /* == CUTTING TOOL START == */ |
---|
203 | |
---|
204 | /* upper cylinder cutout */ |
---|
205 | |
---|
206 | translate([bb_width/2, bb_board_diameter+bb_board_diameter/2, opening_top]) |
---|
207 | { |
---|
208 | rotate([90, 0, 0]) |
---|
209 | { |
---|
210 | cylinder(h=bb_board_diameter*2,r=bb_conn_cutout_radius); |
---|
211 | } |
---|
212 | } |
---|
213 | |
---|
214 | |
---|
215 | translate([(bb_width/2)-bb_conn_cutout_radius, 0, opening_bottom]) |
---|
216 | { |
---|
217 | cube(size = [2*bb_conn_cutout_radius, 18, opening_height]); |
---|
218 | } |
---|
219 | |
---|
220 | /* lower cylinder cutout */ |
---|
221 | |
---|
222 | translate([bb_width/2, bb_board_diameter+bb_board_diameter/2, opening_bottom]) |
---|
223 | { |
---|
224 | rotate([90, 0, 0]) |
---|
225 | { |
---|
226 | cylinder(h=bb_board_diameter*2,r=bb_conn_cutout_radius); |
---|
227 | } |
---|
228 | } |
---|
229 | |
---|
230 | /* == CUTTING TOOL END == */ |
---|
231 | } |
---|
232 | } |
---|
233 | } |
---|
234 | |
---|
235 | /*=======================================================*/ |
---|
236 | /* Assembled Box */ |
---|
237 | /*=======================================================*/ |
---|
238 | |
---|
239 | module bassbox() |
---|
240 | { |
---|
241 | /* |
---|
242 | * Part Dimensions |
---|
243 | */ |
---|
244 | |
---|
245 | top_size = [bb_width, bb_depth, bb_board_diameter]; |
---|
246 | middle_size = [bb_width, bb_depth-bb_intake_space, bb_board_diameter]; |
---|
247 | bottom_size = [bb_width, bb_depth+bb_board_diameter, bb_board_diameter]; |
---|
248 | |
---|
249 | |
---|
250 | /* TODO fix order of dimensions */ |
---|
251 | front_size = [bb_width, 250-9-15, bb_board_diameter]; |
---|
252 | /* TODO fix order of dimensions */ |
---|
253 | side_left_size = [bb_width+(2*bb_board_diameter), bb_height, bb_board_diameter]; |
---|
254 | /* TODO fix order of dimensions */ |
---|
255 | side_right_size = [bb_board_diameter, bb_width+(2*bb_board_diameter), bb_height]; |
---|
256 | back_size = [bb_width, bb_board_diameter, bb_height]; |
---|
257 | |
---|
258 | /* |
---|
259 | * Part Positions |
---|
260 | */ |
---|
261 | |
---|
262 | /* Positions for when assembled. */ |
---|
263 | |
---|
264 | top_pos1 = [bb_board_diameter, bb_board_diameter, bb_height-bb_board_diameter]; |
---|
265 | middle_pos1 = [bb_board_diameter, bb_board_diameter, bb_mid_board_pos+bb_board_diameter]; |
---|
266 | bottom_pos1 = [bb_board_diameter, 0, 0]; |
---|
267 | |
---|
268 | front_pos1 = [bb_board_diameter, 15+bb_board_diameter, -bb_board_diameter]; |
---|
269 | side_left_pos1 = [0, 0, 0]; |
---|
270 | side_right_pos1 = [bb_width+bb_board_diameter, 0, 0]; |
---|
271 | back_pos1 = [bb_board_diameter, bb_depth+bb_board_diameter, 0]; |
---|
272 | |
---|
273 | |
---|
274 | /* Positions for machining the parts. */ |
---|
275 | |
---|
276 | top_pos2 = [0, 210, 0]; |
---|
277 | middle_pos2 = [0, 120, 0]; |
---|
278 | bottom_pos2 = [0, 0, 0]; |
---|
279 | |
---|
280 | front_pos2 = [110, 0, 0]; |
---|
281 | side_left_pos2 = [400, 140, 0]; |
---|
282 | side_right_pos2 = [500, 0, 0]; |
---|
283 | back_pos2 = [220, 0, 0]; |
---|
284 | |
---|
285 | |
---|
286 | /* Invoke parts */ |
---|
287 | |
---|
288 | if (layout_parts == 1) |
---|
289 | { |
---|
290 | /* |
---|
291 | * Invoke parts with positions for machining the parts. |
---|
292 | */ |
---|
293 | |
---|
294 | bb_bottom(bottom_pos2, bottom_size, bottom_color); |
---|
295 | bb_middle(middle_pos2, middle_size, middle_color); |
---|
296 | bb_top(top_pos2, top_size, top_color); |
---|
297 | |
---|
298 | bb_front(front_pos2, front_size, front_color); |
---|
299 | |
---|
300 | bb_part_board_left(side_left_pos2, side_left_size, side_left_color); |
---|
301 | bb_part_board_right(side_right_pos2, side_right_size, side_right_color); |
---|
302 | |
---|
303 | // rotate([90, 0, 0]) |
---|
304 | // { |
---|
305 | bb_part_board_back(back_pos2, back_size, back_color); |
---|
306 | // } |
---|
307 | } |
---|
308 | else |
---|
309 | { |
---|
310 | /* |
---|
311 | * Invoke parts with positions for when the box is assembled. |
---|
312 | */ |
---|
313 | |
---|
314 | if (hide_horizontal_boards == 0) |
---|
315 | { |
---|
316 | bb_bottom(bottom_pos1, bottom_size, bottom_color); |
---|
317 | bb_middle(middle_pos1, middle_size, middle_color); |
---|
318 | bb_top(top_pos1, top_size, top_color); |
---|
319 | } |
---|
320 | |
---|
321 | rotate([90, 0, 0]) { bb_front(front_pos1, front_size, front_color); } |
---|
322 | |
---|
323 | if (hide_sides == 0) |
---|
324 | { |
---|
325 | rotate([90, 0, 90]) { bb_part_board_left(side_left_pos1, side_left_size, side_left_color); } |
---|
326 | bb_part_board_right(side_right_pos1, side_right_size, side_right_color); |
---|
327 | } |
---|
328 | |
---|
329 | bb_part_board_back(back_pos1, back_size, back_color); |
---|
330 | } |
---|
331 | } |
---|
332 | |
---|
333 | /*********************************************************/ |
---|
334 | /* Placing / Invocation */ |
---|
335 | /*********************************************************/ |
---|
336 | |
---|
337 | bassbox(); |
---|