Skip to content

Instantly share code, notes, and snippets.

@sowbug
Created May 6, 2025 18:29
Show Gist options
  • Save sowbug/d06ab16f4bb562a11f6dbee8ee9c3e02 to your computer and use it in GitHub Desktop.
Save sowbug/d06ab16f4bb562a11f6dbee8ee9c3e02 to your computer and use it in GitHub Desktop.
OpenSCAD model of 3mL vial tray for Igloo Legend 6-can cooler
// https://github.com/revarbat/BOSL/wiki/masks.scad#fillet
include <BOSL/constants.scad>
use <BOSL/masks.scad>
test = true;
/////////////////////
vial_diameter = 16.75; // Diameter of the vials in mm
vial_height = 40; // Height of the vials in mm
vial_width = 16.5;
vial_spacing_x = 0; // Space between vials
vial_spacing_y = 1; // Space between vials
max_container_width = 204; // Container width
max_container_depth = 152; // Container depth
max_container_height = 149; // Container height
if (test) {
max_container_width = 80; // Container width
max_container_depth = 50; // Container depth
max_container_height = 40; // Container height
}
wall_thickness = 1; // Thickness of the tray walls
border_margin = 2; // Margin around the tray inside the container
/////////////////////
half_vial_width = vial_width / 2;
// Calculate the maximum tray dimensions to see what fits
max_tray_width = max_container_width - 2 * border_margin;
max_tray_depth = max_container_depth - 2 * border_margin;
max_tray_height = half_vial_width + wall_thickness;
// How many vials can we fit?
// We add the vial spacing to the tray width to compensate for the fact that there are only N-1 spaces between N vials.
vials_x = floor((max_tray_width - 2 * wall_thickness + vial_spacing_x) / (vial_width + vial_spacing_x));
vials_y = floor((max_tray_depth - 2 * wall_thickness + vial_spacing_y) / (vial_height + vial_spacing_y));
// We also want to fit some going sideways
vials_side_x = floor((max_tray_width - 2 * wall_thickness + vial_spacing_y) / (vial_height + vial_spacing_x));
vials_side_y = 1;
// Now calculate the actual tray dimensions
// side_vials_width = vials_side_x * vial_height + (vials_side_x - 1) * vial_spacing_x;
tray_width = ceil(vials_x * (vial_width) + (vials_x - 1) * + vial_spacing_x + 2 * wall_thickness);
side_vials_depth = vials_side_y * vial_width + (vials_side_y - 1) * vial_spacing_y;
tray_depth = ceil(vials_y * (vial_height) + (vials_y - 1) * vial_spacing_y + 2 * wall_thickness + side_vials_depth + vial_spacing_y);
tray_height = ceil(wall_thickness * 1.0 + vial_width * 1.0);
vials_per_tray = vials_x * vials_y + vials_side_x * vials_side_y;
trays_per_container = floor(max_container_height / tray_height);
echo("Container dimensions WxDxH", max_container_width, max_container_depth, max_container_height);
echo("Tray dimensions WxDxH", tray_width, tray_depth, tray_height);
echo("Max vials/tray", vials_per_tray);
echo("Max trays/container", trays_per_container);
echo("Max vials/container", vials_per_tray * trays_per_container);
// The internal dimensions are for subtracting the area inside the tray walls
internal_width = tray_width - wall_thickness * 2;
internal_depth = tray_depth - wall_thickness * 2;
// divided by two because we want to leave something for the cylinder to cut out
internal_height = (tray_height - wall_thickness) / 2;
// vial_x_space = vials_x * (vial_width) + (vials_x - 1) * vial_spacing_x;
vial_y_space = vials_y * (vial_height) + (vials_y - 1) * vial_spacing_y;
// margin_x = (internal_width - vial_x_space) / 2;
// margin_y = (internal_depth - vial_y_space) / 2;
margin_x = 0;
margin_y = 0;
fillet(fillet=2, size = [tray_width, tray_depth, tray_height], $fn=24) {
translate([-tray_width / 2, -tray_depth / 2, -tray_height / 2])
difference() {
// Create the base of the tray
difference() {
cube([tray_width, tray_depth, tray_height]);
translate([wall_thickness, wall_thickness, wall_thickness + tray_height / 2]) {
cube([internal_width, internal_depth, internal_height]);
}
}
// Regular vial orientation
translate([wall_thickness + margin_x,
wall_thickness + margin_y,
wall_thickness + half_vial_width]) {
for (x = [0:vials_x-1]) {
for (y = [0:vials_y-1]) {
translate([half_vial_width + x * (vial_width + vial_spacing_x),
y * (vial_height + vial_spacing_y),
0]) {
rotate([0, 90, 90]) {
cylinder(h = vial_height, d = vial_diameter);
}
}
}
}
}
// Side vial orientation
translate([wall_thickness + margin_x,
wall_thickness + margin_y + vial_y_space + vial_spacing_y,
wall_thickness + half_vial_width]) {
for (x = [0:vials_side_x-1]) {
for (y = [0:vials_side_y-1]) {
translate([vial_height / 2 + x * (vial_height + vial_spacing_y),
half_vial_width + y * (vial_width + vial_spacing_x),
0]) {
rotate([0, 90, 0]) {
cylinder(h = vial_height, d = vial_diameter);
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment