Add parametric_rack_mount.scad
This commit is contained in:
199
parametric_rack_mount.scad
Normal file
199
parametric_rack_mount.scad
Normal file
@@ -0,0 +1,199 @@
|
|||||||
|
rack_units = 2;
|
||||||
|
device_width = 156; // .0001
|
||||||
|
device_height = 81; // .0001
|
||||||
|
device_depth = 156; // .0001
|
||||||
|
|
||||||
|
panel_width = 254;
|
||||||
|
panel_height = rack_units * 44.45;
|
||||||
|
panel_thickness = 4; // .0001
|
||||||
|
shelf_thickness = 4; // .00001
|
||||||
|
lip_height = 4; // .0001
|
||||||
|
lip_thickness = 4; // .0001
|
||||||
|
gusset_thickness = 4; // .0001
|
||||||
|
gusset_depth = 40; // .0001
|
||||||
|
gusset_height = 30; // .0001
|
||||||
|
topshelf_depth = 0; // .0001
|
||||||
|
hole_diameter = 7; // .0001
|
||||||
|
hole_offset_x = 8; // .0001
|
||||||
|
hole_offset_y = 6.25; // .0001
|
||||||
|
corner_radius = 3.81; // .0001
|
||||||
|
// Derived dimensions
|
||||||
|
cutout_width = device_width;
|
||||||
|
cutout_height = device_height;
|
||||||
|
cutout_x = (panel_width - cutout_width) / 2;
|
||||||
|
cutout_y = shelf_thickness;
|
||||||
|
shelf_depth = device_depth + lip_thickness; // Device depth plus 0.25 inches
|
||||||
|
|
||||||
|
|
||||||
|
$fn = 32;
|
||||||
|
|
||||||
|
module roundedcube(size = [1, 1, 1], center = false, radius = 0.5, apply_to = "all") {
|
||||||
|
// If single value, convert to [x, y, z] vector
|
||||||
|
size = (size[0] == undef) ? [size, size, size] : size;
|
||||||
|
|
||||||
|
//echo(str("roundedcube([",size[0],size[1],size[2],"], radius=", radius, ", apply_to=",apply_to));
|
||||||
|
translate_min = 0;
|
||||||
|
translate_xmax = size[0];
|
||||||
|
translate_ymax = size[1];
|
||||||
|
translate_zmax = size[2];
|
||||||
|
|
||||||
|
diameter = radius * 2;
|
||||||
|
|
||||||
|
function adj2(i,dt,df) = (i==0)?dt:df;
|
||||||
|
function adj(i,d) = adj2(i,d,-d);
|
||||||
|
function adjR(i) = adj(i,radius);
|
||||||
|
|
||||||
|
obj_translate = (center == false) ?
|
||||||
|
[0, 0, 0] : [
|
||||||
|
-(size[0] / 2),
|
||||||
|
-(size[1] / 2),
|
||||||
|
-(size[2] / 2)
|
||||||
|
];
|
||||||
|
|
||||||
|
translate(v = obj_translate) {
|
||||||
|
hull() {
|
||||||
|
for (xi = [0:1]) {
|
||||||
|
translate_x = [translate_min, translate_xmax][xi];
|
||||||
|
x_at = (xi == 0) ? "min" : "max";
|
||||||
|
for (yi = [0:1]) {
|
||||||
|
translate_y = [translate_min, translate_ymax][yi];
|
||||||
|
y_at = (yi == 0) ? "min" : "max";
|
||||||
|
for (zi = [0:1]) {
|
||||||
|
translate_z = [translate_min, translate_zmax][zi];
|
||||||
|
z_at = (zi == 0) ? "min" : "max";
|
||||||
|
|
||||||
|
if (
|
||||||
|
(apply_to == "all") ||
|
||||||
|
(apply_to == "xmin" && x_at == "min") || (apply_to == "xmax" && x_at == "max") ||
|
||||||
|
(apply_to == "ymin" && y_at == "min") || (apply_to == "ymax" && y_at == "max") ||
|
||||||
|
(apply_to == "zmin" && z_at == "min") || (apply_to == "zmax" && z_at == "max")
|
||||||
|
) {
|
||||||
|
// GGS: Separate translates to asccomodate changes allowing sizes < 3 x radius
|
||||||
|
translate(v = [translate_x+adjR(xi), translate_y+adjR(yi), translate_z+adjR(zi)])
|
||||||
|
sphere(r = radius);
|
||||||
|
} else {
|
||||||
|
rotate =
|
||||||
|
(apply_to == "xmin" || apply_to == "xmax" || apply_to == "x") ? [0, 90, 0] : (
|
||||||
|
(apply_to == "ymin" || apply_to == "ymax" || apply_to == "y") ? [90, 90, 0] :
|
||||||
|
[0, 0, 0]
|
||||||
|
);
|
||||||
|
//Compute cylinder height to make it work with cubbe sizes up to 3xradius which did not work
|
||||||
|
// in original because cylinders would "eat" spheres
|
||||||
|
h1 =
|
||||||
|
(apply_to == "xmin" || apply_to == "xmax" || apply_to == "x") ? size[0]-radius : (
|
||||||
|
(apply_to == "ymin" || apply_to == "ymax" || apply_to == "y") ? size[1]-radius :
|
||||||
|
size[2]-radius
|
||||||
|
);
|
||||||
|
h2 =
|
||||||
|
(apply_to == "xmin" || apply_to == "xmax" || apply_to == "x") ? size[0]/4 : (
|
||||||
|
(apply_to == "ymin" || apply_to == "ymax" || apply_to == "y") ? size[1]/4 :
|
||||||
|
size[2]/4
|
||||||
|
);
|
||||||
|
h=(h1<h2 && h1>0)?h1:h2;
|
||||||
|
height=(h<radius)?h:radius;
|
||||||
|
echo(height);
|
||||||
|
|
||||||
|
trans =
|
||||||
|
(apply_to == "xmin" || apply_to == "xmax" || apply_to == "x") ? [adj2(xi,0,-height),adjR(yi),adjR(zi)] : (
|
||||||
|
(apply_to == "ymin" || apply_to == "ymax" || apply_to == "y") ? [adjR(xi),adj2(yi,0,-height),adjR(zi)] :
|
||||||
|
[adjR(xi),adjR(yi),adj2(zi,0,-height)]
|
||||||
|
);
|
||||||
|
//echo(trans);
|
||||||
|
translate(v = [translate_x+trans[0], translate_y+trans[1]+height, translate_z+trans[2]])
|
||||||
|
rotate(a = rotate)
|
||||||
|
cylinder(h = height, r = radius, center = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module front_panel() {
|
||||||
|
difference() {
|
||||||
|
// Front panel
|
||||||
|
//cube([panel_width, panel_thickness, panel_height]);
|
||||||
|
roundedcube([panel_width, panel_thickness, panel_height], false, corner_radius, "y");
|
||||||
|
|
||||||
|
// Centered rectangular cutout
|
||||||
|
translate([cutout_x, -1, cutout_y])
|
||||||
|
cube([cutout_width, panel_thickness + 2, cutout_height]);
|
||||||
|
|
||||||
|
// Mounting holes
|
||||||
|
for (x_pos = [hole_offset_x, panel_width - hole_offset_x])
|
||||||
|
for (z_pos = [hole_offset_y, panel_height - hole_offset_y])
|
||||||
|
translate([x_pos, panel_thickness + 1, z_pos])
|
||||||
|
rotate([90, 0, 0])
|
||||||
|
cylinder(h = panel_thickness + 2, d = hole_diameter, $fn = 32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module support_shelf() {
|
||||||
|
// Align top of shelf with bottom of cutout
|
||||||
|
shelf_z = cutout_y;
|
||||||
|
|
||||||
|
// Shelf
|
||||||
|
translate([cutout_x - gusset_thickness, panel_thickness, shelf_z - min(shelf_thickness, (panel_height - device_height) / 2)])
|
||||||
|
cube([cutout_width + gusset_thickness * 2, shelf_depth, min(shelf_thickness, (panel_height - device_height) / 2)]);
|
||||||
|
|
||||||
|
// Back lip
|
||||||
|
translate([cutout_x + device_width / 4, panel_thickness + shelf_depth - lip_thickness, shelf_z ])
|
||||||
|
cube([cutout_width / 2, lip_thickness, lip_height]);
|
||||||
|
}
|
||||||
|
|
||||||
|
module topshelf() {
|
||||||
|
// Align top of shelf with bottom of cutout
|
||||||
|
shelf_z = cutout_y + device_height;
|
||||||
|
|
||||||
|
// Shelf
|
||||||
|
translate([cutout_x - gusset_thickness, panel_thickness, shelf_z - min(shelf_thickness, (panel_height - device_height) / 2)])
|
||||||
|
cube([cutout_width + gusset_thickness * 2, topshelf_depth, min(shelf_thickness, (panel_height - device_height) / 2)]);
|
||||||
|
|
||||||
|
// Left Side
|
||||||
|
translate([cutout_x - gusset_thickness, panel_thickness, shelf_z - min(shelf_thickness, (panel_height - device_height) / 2)])
|
||||||
|
rotate([0,90,0])
|
||||||
|
cube([device_height, topshelf_depth, min(shelf_thickness, (panel_height - device_height) / 2)]);
|
||||||
|
|
||||||
|
// Right Side
|
||||||
|
translate([cutout_x + device_width, panel_thickness, shelf_z - min(shelf_thickness, (panel_height - device_height) / 2)])
|
||||||
|
rotate([0,90,0])
|
||||||
|
cube([device_height, topshelf_depth, min(shelf_thickness, (panel_height - device_height) / 2)]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
module gusset() {
|
||||||
|
// Gusset dimensions
|
||||||
|
//gusset_depth = shelf_depth / 2;
|
||||||
|
//gusset_height = cutout_height / 2;
|
||||||
|
|
||||||
|
// Create a right-angled triangle and extrude it
|
||||||
|
linear_extrude(height = gusset_thickness)
|
||||||
|
polygon(points = [[0, 0], [gusset_depth, 0], [0, gusset_height]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
module gussets() {
|
||||||
|
// Positioning the gussets on either side of the shelf
|
||||||
|
shelf_z = cutout_y;
|
||||||
|
|
||||||
|
// Left gusset
|
||||||
|
translate([cutout_x - gusset_thickness, panel_thickness + topshelf_depth, shelf_z])
|
||||||
|
rotate([90, 0, 90])
|
||||||
|
gusset();
|
||||||
|
|
||||||
|
// Right gusset
|
||||||
|
translate([cutout_x + cutout_width, panel_thickness + topshelf_depth, shelf_z])
|
||||||
|
rotate([90, 0, 90])
|
||||||
|
gusset();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assemble the rack mount
|
||||||
|
//rotate([90, 0, 0])
|
||||||
|
translate([-panel_width / 2, 0, -panel_height / 2])
|
||||||
|
union() {
|
||||||
|
front_panel();
|
||||||
|
support_shelf();
|
||||||
|
topshelf();
|
||||||
|
gussets();
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user