forked from spuder/10-Inch-Rack-OpenSCAD
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10InchRackGenerator.scad
More file actions
418 lines (353 loc) · 16.7 KB
/
10InchRackGenerator.scad
File metadata and controls
418 lines (353 loc) · 16.7 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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
rack_width = 254.0; // [ 254.0:10 inch, 152.4:6 inch]
rack_height = 4.0; // [0.5:0.5:5]
half_height_holes = true; // [true:Show partial holes at edges, false:Hide partial holes]
switch_width = 190.0;
switch_depth = 200.0;
switch_height = 54;
switch_count = 3; // Number of switches to stack
case_thickness = 2; // Thickness of case walls
wire_diameter = 12; // Diameter of power wire holes
zip_tie_hole_width = 3.0; // Width of zip tie slots
front_wire_holes = true; // [true:Show front wire holes with channels, false:Hide]
air_holes = true; // [true:Show air holes, false:Hide air holes]
print_orientation = true; // [true: Place on printbed, false: Facing forward]
tolerance = 0.42;
/* [Hidden] */
// Calculate required height based on switch count
function calc_required_height(count, sw_height, case_thickness) =
let(
wall_thickness = case_thickness,
divider_thickness = case_thickness,
required_height = (2 * wall_thickness) + (count * sw_height) + ((count - 1) * divider_thickness)
) required_height;
// Adjust rack_height if necessary
function adjust_rack_height(count, sw_height, current_rack_height, half_height, case_thickness) =
let(
required_height = calc_required_height(count, sw_height, case_thickness),
required_u = required_height / 44.45
)
(count > 1 && required_u > current_rack_height) ?
(half_height ? required_u : ceil(required_u)) :
current_rack_height;
adjusted_rack_height = adjust_rack_height(switch_count, switch_height, rack_height, half_height_holes, case_thickness);
height = 44.45 * adjusted_rack_height;
// The main module containing all internal variables
module switch_mount(switch_width, switch_height, switch_depth, switch_count, case_thickness, wire_diameter) {
//6 inch racks (mounts=152.4mm; rails=15.875mm; usable space=120.65mm)
//10 inch racks (mounts=254.0mm; rails=15.875mm; usable space=221.5mm)
// Standard chassis width based on switch width
standard_chassis_width = switch_width + (2 * case_thickness);
// Maximum allowed chassis width based on rack size
max_chassis_width = (rack_width == 152.4) ? 120.65 : 221.5;
// Choose chassis width: don't exceed rack limits
chassis_width = min(standard_chassis_width, max_chassis_width);
front_thickness = 3.0;
corner_radius = 4.0;
chassis_edge_radius = 2.0;
// Calculated dimensions for chassis
wall_thickness = case_thickness;
divider_thickness = case_thickness;
zip_tie_hole_count = 8;
zip_tie_hole_length = 5;
// Depth calculations
chassis_depth_main = front_thickness + switch_depth + zip_tie_hole_length + case_thickness;
zip_tie_start_z = front_thickness + switch_depth;
full_chassis_depth = switch_depth + zip_tie_hole_length + case_thickness;
// Shared layout calculations
total_switch_area = (switch_count * switch_height) + ((switch_count - 1) * divider_thickness);
total_chassis_height = total_switch_area + (2 * wall_thickness);
switch_y_start = (height - total_switch_area - (2 * wall_thickness)) / 2 + wall_thickness;
// Wire hole positions (at switch edges)
wire_hole_left_x = (rack_width - switch_width) / 2;
wire_hole_right_x = (rack_width + switch_width) / 2;
// Chassis side margin
side_margin = (rack_width - chassis_width) / 2;
// Y center position for switch at index i
function switch_y_center(i) = switch_y_start + (i * (switch_height + divider_thickness)) + (switch_height / 2);
$fn = 64;
// Helper modules
module capsule_slot_2d(L, H) {
hull() {
translate([-L/2 + H/2, 0]) circle(r=H/2);
translate([L/2 - H/2, 0]) circle(r=H/2);
}
}
module rounded_rect_2d(w, h, r) {
hull() {
translate([r, r]) circle(r=r);
translate([w-r, r]) circle(r=r);
translate([w-r, h-r]) circle(r=r);
translate([r, h-r]) circle(r=r);
}
}
module rounded_chassis_profile(width, height, radius, depth) {
hull() {
translate([radius, radius, 0]) cylinder(h = depth, r = radius);
translate([width - radius, radius, 0]) cylinder(h = depth, r = radius);
translate([radius, height - radius, 0]) cylinder(h = depth, r = radius);
translate([width - radius, height - radius, 0]) cylinder(h = depth, r = radius);
}
}
// Reinforcement brackets connecting front panel tabs to chassis
module reinforcement_brackets() {
// Rail width where mounting holes are located
rail_width = 15.875; // Standard 10-inch rack rail width
bracket_depth = full_chassis_depth * 0.90; // 90% of chassis depth
// Bracket spans from after rail area into chassis (small overlap for clean union)
bracket_start = rail_width + tolerance; // Start after rail
bracket_end = side_margin + 0.1; // Slight overlap into chassis for manifold
bracket_width = bracket_end - bracket_start;
// 2D right triangle profile for gusset
module bracket_profile() {
polygon(points = [
[0, 0],
[bracket_width, 0],
[bracket_width, bracket_depth]
]);
}
// Y positions for brackets: top/bottom of chassis + dividers
// Start brackets where rounded edge ends for cleaner/stronger union
chassis_bottom_y = (height - total_chassis_height) / 2;
chassis_top_y = (height + total_chassis_height) / 2;
// Collect all bracket Y positions (centered for extrusion)
bracket_positions = concat(
[chassis_bottom_y + chassis_edge_radius + case_thickness/2, // Below rounded edge
chassis_top_y - chassis_edge_radius - case_thickness/2], // Above rounded edge
// Internal dividers (between switches) - already centered
[for (i = [0:switch_count-2])
switch_y_start + (i + 1) * switch_height + i * divider_thickness + divider_thickness / 2]
);
for (y_pos = bracket_positions) {
// Left bracket (starts after rail, extends toward chassis)
translate([bracket_start, y_pos, front_thickness]) {
rotate([90, 0, 0]) {
linear_extrude(height = case_thickness, center = true) {
bracket_profile();
}
}
}
// Right bracket (mirrored, starts after rail on right side)
translate([rack_width - bracket_start, y_pos, front_thickness]) {
rotate([90, 0, 0]) {
linear_extrude(height = case_thickness, center = true) {
mirror([1, 0]) bracket_profile();
}
}
}
}
}
// Wire channel reinforcement - adds material around wire holes
module wire_channels() {
channel_diameter = wire_diameter + (2 * case_thickness);
for (i = [0:switch_count-1]) {
for (side_x = [wire_hole_left_x, wire_hole_right_x]) {
translate([side_x, switch_y_center(i), front_thickness]) {
rotate([0, 0, 30]) cylinder(h = full_chassis_depth, d = channel_diameter, $fn = 6);
}
}
}
}
// Create the main body as a separate module
module main_body() {
union() {
// Front panel
linear_extrude(height = front_thickness) {
rounded_rect_2d(rack_width, height, corner_radius);
}
// Chassis body
translate([side_margin, (height - total_chassis_height) / 2, front_thickness]) {
rounded_chassis_profile(chassis_width, total_chassis_height, chassis_edge_radius, full_chassis_depth);
}
if (front_wire_holes) {
wire_channels();
}
// Reinforcement brackets from tabs to chassis
reinforcement_brackets();
}
}
// Create switch cutout with proper lip
module switch_cutout() {
lip_thickness = 1.2;
lip_depth = 0.60;
cutout_w = switch_width + (2 * tolerance);
cutout_h = switch_height + (2 * tolerance);
for (i = [0:switch_count-1]) {
// Main cutout minus lip (centered)
translate([
(rack_width - (cutout_w - 2*lip_thickness)) / 2,
switch_y_center(i) - (cutout_h - 2*lip_thickness) / 2,
-tolerance
]) {
cube([cutout_w - 2*lip_thickness, cutout_h - 2*lip_thickness, chassis_depth_main + 10]);
}
// Switch cutout above the lip (centered)
translate([
(rack_width - cutout_w) / 2,
switch_y_center(i) - cutout_h / 2,
lip_depth
]) {
cube([cutout_w, cutout_h, chassis_depth_main + 10]);
}
}
}
// Create all rack holes
module all_rack_holes() {
// Rack standard: 3 holes per U, with specific positioning
// Each U is 44.45mm, holes are at specific positions within each U
hole_spacing_x = (rack_width == 152.4) ? 136.526 : 236.525; // 6 inch : 10 inch rack
hole_left_x = (rack_width - hole_spacing_x) / 2;
hole_right_x = (rack_width + hole_spacing_x) / 2;
// 10 inch rack = 10x7mm oval
// 6 inch rack = 3.25 x 6.5mm oval
slot_len = (rack_width == 152.4) ? 6.5 : 10.0;
slot_height = (rack_width == 152.4) ? 3.25 : 7.0;
// Standard rack hole positions within each 1U (44.45mm) unit:
// First hole: 6.35mm from top of U
// Second hole: 22.225mm from top of U (middle)
// Third hole: 38.1mm from top of U (6.35mm from bottom)
u_hole_positions = [6.35, 22.225, 38.1]; // positions within each U
// Calculate how many full and partial U units we need to consider
max_u = ceil(adjusted_rack_height); // Include partial U units
for (side_x = [hole_left_x, hole_right_x]) {
for (u = [0:max_u-1]) {
for (hole_pos = u_hole_positions) {
// Calculate hole position from top of entire rack
hole_y = height - (u * 44.45 + hole_pos);
// Always show holes that are at least partially within the rack height
// Always show holes fully inside the rack
fully_inside = (hole_y >= slot_height/2 && hole_y <= height - slot_height/2);
// Show partial holes at edge only if half_height_holes is true
partially_inside = (hole_y + slot_height/2 > 0 && hole_y - slot_height/2 < height);
show_hole = fully_inside || (half_height_holes && partially_inside && !fully_inside);
if (show_hole) {
translate([side_x, hole_y, 0]) {
linear_extrude(height = chassis_depth_main + 10) {
capsule_slot_2d(slot_len, slot_height);
}
}
}
}
}
}
}
// Power wire cutouts: just the wire diameter holes
module power_wire_cutouts() {
for (i = [0:switch_count-1]) {
for (side_x = [wire_hole_left_x, wire_hole_right_x]) {
translate([side_x, switch_y_center(i), 0]) {
rotate([0, 0, 30]) cylinder(h = chassis_depth_main + 10, d = wire_diameter, $fn = 6);
}
}
}
}
// Create zip tie holes - vertical slots spanning entire continuous chassis
module zip_tie_features() {
for (j = [0:zip_tie_hole_count-1]) {
x_pos = wire_hole_left_x + (switch_width / (zip_tie_hole_count + 1)) * (j + 1);
// Extend beyond chassis by tolerance on both ends
translate([x_pos, switch_y_start - wall_thickness - tolerance, zip_tie_start_z]) {
cube([zip_tie_hole_width, total_chassis_height + (2 * tolerance), zip_tie_hole_length]);
}
}
}
// Air holes with staggered honeycomb pattern on back and side faces
module air_holes() {
hole_d = 16;
spacing_x = 17;
spacing_z = 15;
margin = 3;
cutout_buffer = total_chassis_height * 0.05; // 5% buffer for clean cuts
cutout_center_x = rack_width / 2;
cutout_center_z = front_thickness + switch_depth / 2;
// Back face hole dimensions
back_hole_start_y = (height + total_chassis_height) / 2 + cutout_buffer;
back_hole_length = total_chassis_height + (2 * cutout_buffer);
// Side face hole dimensions (extra for wire channel protrusions)
channel_extra = wire_diameter;
side_hole_length = chassis_width + (2 * channel_extra);
for (switch_idx = [0:switch_count-1]) {
// BACK FACE HOLES
available_width = switch_width - (2 * margin);
available_depth = switch_depth - (2 * margin);
x_cols = floor(available_width / spacing_x);
z_rows = floor(available_depth / spacing_z);
actual_grid_width = (x_cols - 1) * spacing_x;
actual_grid_depth = (z_rows - 1) * spacing_z;
x_start = cutout_center_x - actual_grid_width / 2;
z_start = cutout_center_z - actual_grid_depth / 2;
if (x_cols > 0 && z_rows > 0) {
for (i = [0:x_cols-1]) {
for (j = [0:z_rows-1]) {
z_offset = (j % 2 == 1) ? spacing_z/2 : 0;
x_pos = x_start + i * spacing_x + z_offset;
z_pos = z_start + j * spacing_z;
if (z_pos + hole_d/2 <= cutout_center_z + switch_depth/2 - margin &&
z_pos - hole_d/2 >= cutout_center_z - switch_depth/2 + margin) {
translate([x_pos, back_hole_start_y, z_pos]) {
rotate([90, 30, 0]) {
cylinder(h = back_hole_length, d = hole_d, $fn = 6);
}
}
}
}
}
}
// SIDE FACE HOLES
available_height = switch_height - (2 * margin);
available_side_depth = switch_depth - (2 * margin);
y_cols = floor(available_height / spacing_x);
z_rows_side = floor(available_side_depth / spacing_z);
actual_grid_height = (y_cols - 1) * spacing_x;
actual_grid_depth_side = (z_rows_side - 1) * spacing_z;
y_start_holes = switch_y_center(switch_idx) - actual_grid_height / 2;
z_start_side = cutout_center_z - actual_grid_depth_side / 2;
if (y_cols > 0 && z_rows_side > 0) {
for (side = [0, 1]) {
// Offset outward to reach wire channel protrusions
side_x = side == 0 ? side_margin - channel_extra : rack_width - side_margin + channel_extra;
rot_angle = side == 0 ? 90 : -90;
for (i = [0:y_cols-1]) {
for (j = [0:z_rows_side-1]) {
z_offset = (j % 2 == 1) ? spacing_z/2 : 0;
y_pos = y_start_holes + i * spacing_x + z_offset;
z_pos = z_start_side + j * spacing_z;
if (z_pos + hole_d/2 <= cutout_center_z + switch_depth/2 - margin &&
z_pos - hole_d/2 >= cutout_center_z - switch_depth/2 + margin) {
translate([side_x, y_pos, z_pos]) {
rotate([0, rot_angle, 0]) {
cylinder(h = side_hole_length, d = hole_d, $fn = 6);
}
}
}
}
}
}
}
}
}
// Main assembly
translate([-rack_width/2, -height/2, 0]) {
difference() {
main_body();
union() {
switch_cutout();
all_rack_holes();
zip_tie_features();
if (front_wire_holes) {
power_wire_cutouts();
}
if (air_holes) {
air_holes();
}
}
}
}
}
// Call the module
if (print_orientation) {
switch_mount(switch_width, switch_height, switch_depth, switch_count, case_thickness, wire_diameter);
} else {
rotate([-90,0,0])
translate([0, -height/2, -switch_depth/2])
switch_mount(switch_width, switch_height, switch_depth, switch_count, case_thickness, wire_diameter);
}