Skip to content

Instantly share code, notes, and snippets.

@mikolak-net
Created October 28, 2025 23:06
Show Gist options
  • Select an option

  • Save mikolak-net/96f6fbfde61354d19bc9482e66a93349 to your computer and use it in GitHub Desktop.

Select an option

Save mikolak-net/96f6fbfde61354d19bc9482e66a93349 to your computer and use it in GitHub Desktop.
// Tray with 4 compartments and magnet voids
// Dimensions: 50mm x 50mm
// Parameters
tray_width = 50;
tray_length = 50;
wall_height = 5;
wall_thickness = 1.2;
base_thickness = 3;
magnet_width = 4;
magnet_length = 10;
magnet_height = 2;
magnet_offset_from_top = 0.6; // Distance from top of base to top of magnet void
// Calculate internal dimensions
inner_width = tray_width - 2 * wall_thickness;
inner_length = tray_length - 2 * wall_thickness;
compartment_width = (inner_width - wall_thickness) / 2;
compartment_length = (inner_length - wall_thickness) / 2;
module base() {
difference() {
// Base plate
cube([tray_width, tray_length, base_thickness]);
// Magnet voids in each compartment
// Top-left compartment
translate([
wall_thickness + compartment_width/2 - magnet_width/2,
wall_thickness + compartment_length/2 - magnet_length/2,
base_thickness - magnet_height - magnet_offset_from_top
])
cube([magnet_width, magnet_length, magnet_height]);
// Top-right compartment
translate([
wall_thickness + compartment_width + wall_thickness + compartment_width/2 - magnet_width/2,
wall_thickness + compartment_length/2 - magnet_length/2,
base_thickness - magnet_height - magnet_offset_from_top
])
cube([magnet_width, magnet_length, magnet_height]);
// Bottom-left compartment
translate([
wall_thickness + compartment_width/2 - magnet_width/2,
wall_thickness + compartment_length + wall_thickness + compartment_length/2 - magnet_length/2,
base_thickness - magnet_height - magnet_offset_from_top
])
cube([magnet_width, magnet_length, magnet_height]);
// Bottom-right compartment
translate([
wall_thickness + compartment_width + wall_thickness + compartment_width/2 - magnet_width/2,
wall_thickness + compartment_length + wall_thickness + compartment_length/2 - magnet_length/2,
base_thickness - magnet_height - magnet_offset_from_top
])
cube([magnet_width, magnet_length, magnet_height]);
}
}
module walls() {
// Outer walls
difference() {
cube([tray_width, tray_length, wall_height + base_thickness]);
translate([wall_thickness, wall_thickness, base_thickness])
cube([inner_width, inner_length, wall_height + 1]);
}
// Horizontal divider
translate([wall_thickness, tray_length/2 - wall_thickness/2, base_thickness])
cube([inner_width, wall_thickness, wall_height]);
// Vertical divider
translate([tray_width/2 - wall_thickness/2, wall_thickness, base_thickness])
cube([wall_thickness, inner_length, wall_height]);
}
// Render the complete tray
base();
walls();
// Tray dimensions
tray_width = 50;
tray_length = 50;
tray_wall_height = 5;
tray_wall_thickness = 1.2;
tray_base_thickness = 3;
magnet_width = 4;
magnet_length = 10;
magnet_height = 2;
magnet_clearance = 0.6;
// Calculate compartment size
compartment_count = 4;
compartment_width = tray_width / 2;
compartment_length = tray_length / 2;
// Calculate magnet pocket position (center of each compartment)
magnet_pocket_x = compartment_width / 2;
magnet_pocket_y = compartment_length / 2;
// Create the base with magnet pockets
module create_base() {
difference() {
// Base plate
cube([tray_width, tray_length, tray_base_thickness]);
// Magnet pockets (one in each compartment)
// Calculate correct Z position: from base bottom + clearance + magnet height
magnet_z_position = tray_base_thickness - magnet_height - magnet_clearance;
translate([magnet_pocket_x - magnet_width/2, magnet_pocket_y - magnet_length/2, magnet_z_position])
cube([magnet_width, magnet_length, magnet_height]);
translate([tray_width - magnet_pocket_x - magnet_width/2, magnet_pocket_y - magnet_length/2, magnet_z_position])
cube([magnet_width, magnet_length, magnet_height]);
translate([magnet_pocket_x - magnet_width/2, tray_length - magnet_pocket_y - magnet_length/2, magnet_z_position])
cube([magnet_width, magnet_length, magnet_height]);
translate([tray_width - magnet_pocket_x - magnet_width/2, tray_length - magnet_pocket_y - magnet_length/2, magnet_z_position])
cube([magnet_width, magnet_length, magnet_height]);
}
}
// Create the walls and dividers
module create_walls() {
// External walls - properly aligned with base and accounting for base thickness
union() {
// Left and right walls
translate([0, 0, tray_base_thickness])
cube([tray_wall_thickness, tray_length, tray_wall_height]);
translate([tray_width - tray_wall_thickness, 0, tray_base_thickness])
cube([tray_wall_thickness, tray_length, tray_wall_height]);
// Front and back walls
translate([0, 0, tray_base_thickness])
cube([tray_width, tray_wall_thickness, tray_wall_height]);
translate([0, tray_length - tray_wall_thickness, tray_base_thickness])
cube([tray_width, tray_wall_thickness, tray_wall_height]);
}
// Internal dividers - properly aligned with base and accounting for base thickness
union() {
// Vertical divider
translate([tray_width/2, 0, tray_base_thickness])
cube([tray_wall_thickness, tray_length, tray_wall_height]);
// Horizontal divider
translate([0, tray_length/2, tray_base_thickness])
cube([tray_width, tray_wall_thickness, tray_wall_height]);
}
}
// Assemble the tray
module tray() {
create_base();
create_walls();
}
// Render the tray
tray();
// Tray dimensions
tray_width = 50;
tray_length = 50;
tray_wall_height = 5;
tray_wall_thickness = 1.2;
tray_base_thickness = 3;
magnet_width = 4;
magnet_length = 10;
magnet_height = 2;
magnet_clearance = 0.6;
// Calculate compartment size
compartment_count = 4;
compartment_width = tray_width / 2;
compartment_length = tray_length / 2;
// Calculate magnet pocket position (center of each compartment)
magnet_pocket_x = compartment_width / 2;
magnet_pocket_y = compartment_length / 2;
// Create the base with magnet pockets
module create_base() {
difference() {
// Base plate
cube([tray_width, tray_length, tray_base_thickness]);
// Magnet pockets (one in each compartment)
translate([magnet_pocket_x - magnet_width/2, magnet_pocket_y - magnet_length/2, -magnet_clearance])
cube([magnet_width, magnet_length, magnet_height + magnet_clearance + tray_base_thickness]);
translate([tray_width - magnet_pocket_x - magnet_width/2, magnet_pocket_y - magnet_length/2, -magnet_clearance])
cube([magnet_width, magnet_length, magnet_height + magnet_clearance + tray_base_thickness]);
translate([magnet_pocket_x - magnet_width/2, tray_length - magnet_pocket_y - magnet_length/2, -magnet_clearance])
cube([magnet_width, magnet_length, magnet_height + magnet_clearance + tray_base_thickness]);
translate([tray_width - magnet_pocket_x - magnet_width/2, tray_length - magnet_pocket_y - magnet_length/2, -magnet_clearance])
cube([magnet_width, magnet_length, magnet_height + magnet_clearance + tray_base_thickness]);
}
}
// Create the walls and dividers
module create_walls() {
// External walls
union() {
// Left and right walls
translate([0, 0, 0])
cube([tray_wall_thickness, tray_length + 2*tray_wall_thickness, tray_wall_height]);
translate([tray_width, 0, 0])
cube([tray_wall_thickness, tray_length + 2*tray_wall_thickness, tray_wall_height]);
// Front and back walls
translate([0, 0, 0])
cube([tray_width + 2*tray_wall_thickness, tray_wall_thickness, tray_wall_height]);
translate([0, tray_length, 0])
cube([tray_width + 2*tray_wall_thickness, tray_wall_thickness, tray_wall_height]);
}
// Internal dividers
union() {
// Vertical divider
translate([tray_width/2, 0, 0])
cube([tray_wall_thickness, tray_length + 2*tray_wall_thickness, tray_wall_height]);
// Horizontal divider
translate([0, tray_length/2, 0])
cube([tray_width + 2*tray_wall_thickness, tray_wall_thickness, tray_wall_height]);
}
}
// Assemble the tray
module tray() {
create_base();
create_walls();
}
// Render the tray
tray();
// Tray dimensions
tray_x = 50;
tray_y = 50;
wall_height = 5;
wall_thickness = 1.2;
base_thickness = 3;
// Magnet dimensions
magnet_x = 10;
magnet_y = 4;
magnet_z = 2;
// Distance from the top surface of the base to the top of the magnet void
magnet_top_offset = 0.6;
// --- Calculations (do not modify) ---
inner_x = tray_x - 2 * wall_thickness;
inner_y = tray_y - 2 * wall_thickness;
compartment_x = (inner_x - wall_thickness) / 2;
compartment_y = (inner_y - wall_thickness) / 2;
magnet_pos_z = base_thickness - magnet_top_offset - magnet_z;
// --- Modules ---
// Module to create the four magnet voids
module magnet_voids() {
// Calculate center positions for one quadrant and mirror
cx = wall_thickness + compartment_x / 2;
cy = wall_thickness + compartment_y / 2;
// Bottom-left
translate([cx, cy, magnet_pos_z])
cube([magnet_x, magnet_y, magnet_z], center=true);
// Bottom-right
translate([tray_x - cx, cy, magnet_pos_z])
cube([magnet_x, magnet_y, magnet_z], center=true);
// Top-left
translate([cx, tray_y - cy, magnet_pos_z])
cube([magnet_x, magnet_y, magnet_z], center=true);
// Top-right
translate([tray_x - cx, tray_y - cy, magnet_pos_z])
cube([magnet_x, magnet_y, magnet_z], center=true);
}
// --- Model ---
difference() {
// Main tray body with dividers
union() {
// Base and outer walls
difference() {
cube([tray_x, tray_y, base_thickness + wall_height]);
translate([wall_thickness, wall_thickness, base_thickness])
cube([inner_x, inner_y, wall_height + 0.1]); // +0.1 to ensure clean subtraction
}
// Vertical divider
translate([wall_thickness + compartment_x, wall_thickness, base_thickness])
cube([wall_thickness, inner_y, wall_height]);
// Horizontal divider
translate([wall_thickness, wall_thickness + compartment_y, base_thickness])
cube([inner_x, wall_thickness, wall_height]);
}
// Subtract magnet voids
magnet_voids();
}
// Tray dimensions
tray_width = 50; // mm
tray_length = 50; // mm
tray_height_base = 3; // mm
wall_thickness = 1.2; // mm
wall_height = 5; // mm
compartment_size = tray_width / 2; // 25mm each
// Magnet dimensions
magnet_width = 4; // mm
magnet_length = 10; // mm
magnet_height = 2; // mm
magnet_depth_offset = 0.6; // mm from top of base
// Calculate positions for magnet voids
magnet_x = compartment_size / 2 - magnet_length / 2;
magnet_y = compartment_size / 2 - magnet_width / 2;
magnet_z = tray_height_base - magnet_depth_offset - magnet_height;
// Generate the tray
difference() {
// Base and walls combined
union() {
// Base
cube([tray_width, tray_length, tray_height_base], center=false);
// External walls
translate([0, 0, tray_height_base])
cube([wall_thickness, tray_length, wall_height]); // Left wall
translate([tray_width - wall_thickness, 0, tray_height_base])
cube([wall_thickness, tray_length, wall_height]); // Right wall
translate([0, 0, tray_height_base])
cube([tray_width, wall_thickness, wall_height]); // Bottom wall
translate([0, tray_length - wall_thickness, tray_height_base])
cube([tray_width, wall_thickness, wall_height]); // Top wall
// Internal dividers
translate([compartment_size, 0, tray_height_base])
cube([wall_thickness, tray_length, wall_height]); // Vertical divider
translate([0, compartment_size, tray_height_base])
cube([tray_width, wall_thickness, wall_height]); // Horizontal divider
}
// Magnet voids in each compartment
translate([magnet_x, magnet_y, magnet_z])
cube([magnet_length, magnet_width, magnet_height]); // Bottom-left
translate([magnet_x + compartment_size, magnet_y, magnet_z])
cube([magnet_length, magnet_width, magnet_height]); // Bottom-right
translate([magnet_x, magnet_y + compartment_size, magnet_z])
cube([magnet_length, magnet_width, magnet_height]); // Top-left
translate([magnet_x + compartment_size, magnet_y + compartment_size, magnet_z])
cube([magnet_length, magnet_width, magnet_height]); // Top-right
}
// Tray dimensions
outer_width = 50; // External width in mm
outer_length = 50; // External length in mm
wall_height = 5; // Total height of walls in mm
wall_thickness = 1.2; // Width of walls and dividers in mm
base_thickness = 3; // Thickness of base in mm
// Magnet void dimensions
magnet_width = 4; // Width of magnet void in mm
magnet_length = 10; // Length of magnet void in mm
magnet_depth = 2; // Depth of magnet void in mm
// Calculate inner dimensions
inner_width = outer_width - 2 * wall_thickness;
inner_length = outer_length - 2 * wall_thickness;
// Calculate compartment size
compartment_width = inner_width / 2;
compartment_length = inner_length / 2;
// Calculate magnet void positions
void_x_offset = (compartment_width - magnet_width) / 2;
void_y_offset = (compartment_length - magnet_length) / 2;
// Base positions
base_x_start = wall_thickness;
base_y_start = wall_thickness;
base_z = 0;
// Wall positions
wall_x = outer_width - wall_thickness;
wall_y = outer_length - wall_thickness;
wall_z = base_thickness;
// Divider positions
divider1_x = outer_width / 2;
divider2_y = outer_length / 2;
// Create the main tray
difference() {
// Outer shell
cube([outer_width, outer_length, wall_height]);
// Inner cavity (subtract to create walls)
translate([wall_thickness, wall_thickness, 0])
cube([inner_width, inner_length, wall_height]);
// Top cavity (to create base thickness)
translate([0, 0, base_thickness])
cube([outer_width, outer_length, wall_height - base_thickness]);
// Add divider cutouts
// Vertical divider
translate([divider1_x - wall_thickness/2, 0, 0])
cube([wall_thickness, outer_length, base_thickness]);
// Horizontal divider
translate([0, divider2_y - wall_thickness/2, 0])
cube([outer_width, wall_thickness, base_thickness]);
}
// Add magnet voids
// Bottom-left compartment
translate([base_x_start + void_x_offset, base_y_start + void_y_offset, 0])
cube([magnet_width, magnet_length, magnet_depth]);
// Bottom-right compartment
translate([base_x_start + compartment_width + void_x_offset, base_y_start + void_y_offset, 0])
cube([magnet_width, magnet_length, magnet_depth]);
// Top-left compartment
translate([base_x_start + void_x_offset, base_y_start + compartment_length + void_y_offset, 0])
cube([magnet_width, magnet_length, magnet_depth]);
// Top-right compartment
translate([base_x_start + compartment_width + void_x_offset, base_y_start + compartment_length + void_y_offset, 0])
cube([magnet_width, magnet_length, magnet_depth]);
// Tray parameters
tray_size = 50;
wall_thickness = 1.2;
divider_thickness = 1.2;
wall_height = 5; // Height above the base
base_thickness = 3;
tray_height = base_thickness + wall_height;
// Magnet void parameters
magnet_x = 4;
magnet_y = 10;
magnet_z = 2;
magnet_offset_from_top = 0.6;
// Derived values
compartments = 2;
inner_size = tray_size - 2 * wall_thickness;
compartment_size = (inner_size - divider_thickness) / compartments;
// Helper: position of magnet voids (center of each compartment)
function compartment_center(i, j) = [
wall_thickness + compartment_size / 2 + i * (compartment_size + divider_thickness),
wall_thickness + compartment_size / 2 + j * (compartment_size + divider_thickness)
];
// Main tray with solid dividers
difference() {
// Full tray block (including dividers)
cube([tray_size, tray_size, tray_height]);
// Subtract compartment voids (leave dividers as solid)
for (i = [0:1], j = [0:1]) {
translate([
wall_thickness + i * (compartment_size + divider_thickness),
wall_thickness + j * (compartment_size + divider_thickness),
base_thickness
])
cube([compartment_size, compartment_size, wall_height]);
}
// Magnet voids
for (i = [0:1], j = [0:1]) {
center = compartment_center(i, j);
translate([
center[0] - magnet_x / 2,
center[1] - magnet_y / 2,
base_thickness - magnet_offset_from_top - magnet_z
])
cube([magnet_x, magnet_y, magnet_z]);
}
}
// Tray parameters
tray_size = 50;
wall_thickness = 1.2;
divider_thickness = 1.2;
tray_height = 5;
base_thickness = 3;
// Magnet void parameters
magnet_x = 4;
magnet_y = 10;
magnet_z = 2;
magnet_offset_from_top = 0.6;
// Derived values
compartments = 2;
inner_size = tray_size - 2 * wall_thickness;
compartment_size = (inner_size - divider_thickness) / compartments;
// Helper: position of magnet voids (center of each compartment)
function compartment_center(i, j) = [
wall_thickness + compartment_size / 2 + i * (compartment_size + divider_thickness),
wall_thickness + compartment_size / 2 + j * (compartment_size + divider_thickness)
];
// Main tray
difference() {
// Outer tray
cube([tray_size, tray_size, tray_height]);
// Hollow out compartments
translate([wall_thickness, wall_thickness, base_thickness])
cube([inner_size, inner_size, tray_height - base_thickness]);
// Vertical divider (X)
translate([wall_thickness + compartment_size, wall_thickness, 0])
cube([divider_thickness, inner_size, tray_height]);
// Horizontal divider (Y)
translate([wall_thickness, wall_thickness + compartment_size, 0])
cube([inner_size, divider_thickness, tray_height]);
// Magnet voids
for (i = [0:1], j = [0:1]) {
center = compartment_center(i, j);
translate([
center[0] - magnet_x / 2,
center[1] - magnet_y / 2,
base_thickness - magnet_z + magnet_offset_from_top
])
cube([magnet_x, magnet_y, magnet_z]);
}
}
//------------------------------------------------------------
// 50 × 50 mm Tray with 4 compartments
// - External walls: 5 mm tall, 1.2 mm wide
// - Base: 3 mm thick
// - Magnet voids (4 × 10 × 2 mm) centered in each compartment
// and no more than 0.6 mm from the base top
//------------------------------------------------------------
// ==================== Tray parameters ====================
tray_size = 50; // tray dimensions (mm)
wall_thickness = 1.2; // wall thickness (mm)
wall_height = 5; // wall height (mm)
base_thickness = 3; // base thickness (mm)
// ==================== Magnet void parameters ====================
magnet_size = [4, 10, 2]; // magnet dimensions (mm)
magnet_depth_top = 0.6; // distance from top of base to top of void (mm)
magnet_z_bottom = base_thickness - magnet_depth_top - magnet_size[2]; // z of void bottom
// ==================== Compartment centers ====================
// After the outer walls (1.2 mm) and the divider wall (1.2 mm),
// each compartment is 23.2 × 23.2 mm. The centers are:
center1 = [12.8, 12.8];
center2 = [37.2, 12.8];
center3 = [12.8, 37.2];
center4 = [37.2, 37.2];
// ==================== Modules ====================
// Base with magnet voids
module base_with_voids() {
difference() {
cube([tray_size, tray_size, base_thickness]); // solid base
// Subtract the four magnet voids
for (c = [center1, center2, center3, center4]) {
translate([c[0] - magnet_size[0]/2,
c[1] - magnet_size[1]/2,
magnet_z_bottom])
cube(magnet_size);
}
}
}
// Outer (external) walls
module outer_walls() {
difference() {
translate([0, 0, base_thickness]) // place walls on top of base
cube([tray_size, tray_size, wall_height]); // outer shell
translate([wall_thickness, wall_thickness, base_thickness])
cube([tray_size - 2*wall_thickness,
tray_size - 2*wall_thickness,
wall_height]); // inner cavity
}
}
// Divider walls (vertical and horizontal)
module divider_walls() {
// Vertical divider (x‑direction)
translate([25 - wall_thickness/2, wall_thickness, base_thickness])
cube([wall_thickness,
tray_size - 2*wall_thickness,
wall_height]);
// Horizontal divider (y‑direction)
translate([wall_thickness, 25 - wall_thickness/2, base_thickness])
cube([tray_size - 2*wall_thickness,
wall_thickness,
wall_height]);
}
// ==================== Assemble the Tray ====================
union() {
base_with_voids(); // base with voids
outer_walls(); // external walls
divider_walls(); // internal dividers
}
// 50mm x 50mm tray with 4 compartments
// Divider and walls: 5mm tall, 1.2mm wide
// Base: at least 3mm thick
// Magnets: 4mm x 10mm x 2mm, centered in each compartment
// Dimensions
tray_width = 50;
tray_length = 50;
wall_height = 5;
wall_thickness = 1.2;
base_thickness = 3;
magnet_width = 4;
magnet_length = 10;
magnet_height = 2;
max_distance_from_top = 0.6;
// Calculate compartment dimensions
compartment_width = tray_width / 2;
compartment_length = tray_length / 2;
// Main tray module
module tray() {
// Base
difference() {
// Base plate
cube([tray_width, tray_length, base_thickness]);
// Magnet voids (4 total - one per compartment)
// Create 2x2 grid of compartments
for (i = [0:1]) {
for (j = [0:1]) {
// Calculate compartment center
x_center = i * compartment_width + compartment_width/2;
y_center = j * compartment_length + compartment_length/2;
// Calculate bottom-left corner for translation
x_pos = x_center - magnet_width/2;
y_pos = y_center - magnet_length/2;
// Position so top of void is 0.6mm from base top
// If base is at z=0 to z=base_thickness, then base_top is at z=base_thickness
// Top of void should be at z=base_thickness - max_distance_from_top
// Void height is magnet_height + max_distance_from_top (but that doesn't work)
// The void should be positioned so that its top surface is at base_thickness - max_distance_from_top
// The void itself is magnet_height tall, so we subtract that from the top position
z_pos = (base_thickness - max_distance_from_top) - magnet_height;
translate([x_pos, y_pos, z_pos])
cube([magnet_width, magnet_length, magnet_height]);
}
}
}
// External walls
// Bottom wall
translate([0, 0, base_thickness])
cube([tray_width, wall_thickness, wall_height]);
// Top wall
translate([0, tray_length - wall_thickness, base_thickness])
cube([tray_width, wall_thickness, wall_height]);
// Left wall
translate([0, 0, base_thickness])
cube([wall_thickness, tray_length, wall_height]);
// Right wall
translate([tray_width - wall_thickness, 0, base_thickness])
cube([wall_thickness, tray_length, wall_height]);
// Internal dividers
// Vertical divider
translate([compartment_width - wall_thickness/2, 0, base_thickness])
cube([wall_thickness, tray_length, wall_height]);
// Horizontal divider
translate([0, compartment_length - wall_thickness/2, base_thickness])
cube([tray_width, wall_thickness, wall_height]);
}
// Render the tray
tray();
// 50mm x 50mm tray with 4 compartments
// Divider and walls: 5mm tall, 1.2mm wide
// Base: at least 3mm thick
// Magnets: 4mm x 10mm x 2mm, centered in each compartment
// Dimensions
tray_width = 50;
tray_length = 50;
wall_height = 5;
wall_thickness = 1.2;
base_thickness = 3;
magnet_width = 4;
magnet_length = 10;
magnet_height = 2;
max_distance_from_top = 0.6; // Maximum distance from top of base to top of void
// Calculate compartment dimensions
compartment_width = tray_width / 2;
compartment_length = tray_length / 2;
// Main tray module
module tray() {
// Base
difference() {
// Base plate
cube([tray_width, tray_length, base_thickness]);
// Magnet voids (4 total - one per compartment)
// Position so that the top of the void is no more than 0.6mm from the top of the base
// So the void should start at base_thickness - max_distance_from_top - magnet_height
// and have height magnet_height + max_distance_from_top
// Compartment 1 (bottom-left)
translate([(-tray_width/2 + compartment_width/2), (-tray_length/2 + compartment_length/2), base_thickness - magnet_height - max_distance_from_top])
cube([magnet_width, magnet_length, magnet_height + max_distance_from_top]);
// Compartment 2 (bottom-right)
translate([(tray_width/2 - compartment_width/2), (-tray_length/2 + compartment_length/2), base_thickness - magnet_height - max_distance_from_top])
cube([magnet_width, magnet_length, magnet_height + max_distance_from_top]);
// Compartment 3 (top-left)
translate([(-tray_width/2 + compartment_width/2), (tray_length/2 - compartment_length/2), base_thickness - magnet_height - max_distance_from_top])
cube([magnet_width, magnet_length, magnet_height + max_distance_from_top]);
// Compartment 4 (top-right)
translate([(tray_width/2 - compartment_width/2), (tray_length/2 - compartment_length/2), base_thickness - magnet_height - max_distance_from_top])
cube([magnet_width, magnet_length, magnet_height + max_distance_from_top]);
}
// External walls
// Bottom wall
translate([0, 0, base_thickness])
cube([tray_width, wall_thickness, wall_height]);
// Top wall
translate([0, tray_length - wall_thickness, base_thickness])
cube([tray_width, wall_thickness, wall_height]);
// Left wall
translate([0, 0, base_thickness])
cube([wall_thickness, tray_length, wall_height]);
// Right wall
translate([tray_width - wall_thickness, 0, base_thickness])
cube([wall_thickness, tray_length, wall_height]);
// Internal dividers
// Vertical divider
translate([compartment_width - wall_thickness/2, 0, base_thickness])
cube([wall_thickness, tray_length, wall_height]);
// Horizontal divider
translate([0, compartment_length - wall_thickness/2, base_thickness])
cube([tray_width, wall_thickness, wall_height]);
}
// Render the tray
tray();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment