commit 10d91d173a2c26bfb02331e9abeefd45ab11e1db Author: YoungSoo Shin Date: Thu Jul 31 22:28:24 2025 +0900 Add parametric_rack_mount.scad diff --git a/parametric_rack_mount.scad b/parametric_rack_mount.scad new file mode 100644 index 0000000..864a2dd --- /dev/null +++ b/parametric_rack_mount.scad @@ -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

0)?h1:h2; + height=(h