diff --git a/hex-nespresso-insert/hex-nespresso-insert-variant.scad b/hex-nespresso-insert/hex-nespresso-insert-variant.scad new file mode 100644 index 0000000..2863a02 --- /dev/null +++ b/hex-nespresso-insert/hex-nespresso-insert-variant.scad @@ -0,0 +1,119 @@ +/* https://github.com/BelfrySCAD/BOSL2 */ +include + +$fn = 150; + +pattern_width = 375; // Total width of pattern (mm) +pattern_height = 220; // Total height of pattern (mm) +pattern_thickness = 4; // Thickness of the entire pattern (mm) +ring_inner_diameter = 38; // Inner diameter of rings (mm) +ring_width = 2; // Width of ring walls (mm) +line_width = 2; // Width of connecting lines (mm) +perimeter_width = 4; // Width of outer perimeter walls (mm) +hex_spacing = 45; // Distance between hex centers (mm) + +ring_outer_radius = (ring_inner_diameter + 2 * ring_width) / 2; + +module hex_ring_pattern_2d() { + union() { + // Create outer rectangular perimeter using difference + difference() { + square([pattern_width, pattern_height], center=true); + square([pattern_width - 2*perimeter_width, pattern_height - 2*perimeter_width], center=true); + } + + // Get all valid ring positions + positions = get_hex_positions(); + + // Create rings at all valid positions + for (pos = positions) { + translate(pos) ring(r=ring_inner_diameter/2, ring_width=ring_width); + } + + // Create all connections + create_connections(positions); + } +} + +// Function to get all valid hexagonal ring positions +function get_hex_positions() = [ + for (row = [-8:8]) + for (col = [-10:10]) let( + x_pos = col * hex_spacing + (row % 2) * hex_spacing/2, + y_pos = row * hex_spacing * sin(60), + pos = [x_pos, y_pos] + ) + if (abs(x_pos) + ring_outer_radius <= pattern_width/2 && + abs(y_pos) + ring_outer_radius <= pattern_height/2) + pos +]; + +// Create all connections (hex grid + perimeter) +module create_connections(positions) { + if (len(positions) > 1) { + // Hex grid connections + for (i = [0:len(positions)-2]) { + for (j = [i+1:len(positions)-1]) { + pos1 = positions[i]; + pos2 = positions[j]; + dist = norm(pos2 - pos1); + + // Connect adjacent rings + if (dist > hex_spacing * 0.9 && dist < hex_spacing * 1.1) { + connect_rings(pos1, pos2); + } + } + } + + // Perimeter connections + for (pos = positions) { + connect_to_edges(pos); + } + } +} + +// Connect two rings with a line +module connect_rings(pos1, pos2) { + angle = atan2(pos2[1] - pos1[1], pos2[0] - pos1[0]); + start_point = pos1 + [cos(angle), sin(angle)] * (ring_inner_diameter/2); + end_point = pos2 - [cos(angle), sin(angle)] * (ring_inner_diameter/2); + + move((start_point + end_point)/2) + rot(angle) + square([norm(end_point - start_point), line_width], center=true); +} + +// Connect a ring to nearby perimeter edges +module connect_to_edges(pos) { + x = pos[0]; y = pos[1]; + half_w = pattern_width/2; half_h = pattern_height/2; + + // Connect to edges if ring is within 1.5 spacing units + if (x <= -half_w + hex_spacing * 1.5 && abs(y) <= half_h - perimeter_width) { + start = [x - ring_inner_diameter/2, y]; + end = [-half_w, y]; + move((start + end)/2) square([norm(end - start), line_width], center=true); + } + + if (x >= half_w - hex_spacing * 1.5 && abs(y) <= half_h - perimeter_width) { + start = [x + ring_inner_diameter/2, y]; + end = [half_w, y]; + move((start + end)/2) square([norm(end - start), line_width], center=true); + } + + if (y >= half_h - hex_spacing * 1.5 && abs(x) <= half_w - perimeter_width) { + start = [x, y + ring_inner_diameter/2]; + end = [x, half_h]; + move((start + end)/2) rot(90) square([norm(end - start), line_width], center=true); + } + + if (y <= -half_h + hex_spacing * 1.5 && abs(x) <= half_w - perimeter_width) { + start = [x, y - ring_inner_diameter/2]; + end = [x, -half_h]; + move((start + end)/2) rot(90) square([norm(end - start), line_width], center=true); + } +} + +linear_extrude(pattern_thickness) { + hex_ring_pattern_2d(); +} diff --git a/hex-nespresso-insert/hex-nespresso-insert.3mf b/hex-nespresso-insert/hex-nespresso-insert.3mf index 7e99ca6..9dc5c42 100644 Binary files a/hex-nespresso-insert/hex-nespresso-insert.3mf and b/hex-nespresso-insert/hex-nespresso-insert.3mf differ diff --git a/hex-nespresso-insert/hex-nespresso-insert.png b/hex-nespresso-insert/hex-nespresso-insert.png index 02355c4..663d836 100644 Binary files a/hex-nespresso-insert/hex-nespresso-insert.png and b/hex-nespresso-insert/hex-nespresso-insert.png differ diff --git a/hex-nespresso-insert/hex-nespresso-insert.scad b/hex-nespresso-insert/hex-nespresso-insert.scad index 3ac6441..251ffa0 100644 --- a/hex-nespresso-insert/hex-nespresso-insert.scad +++ b/hex-nespresso-insert/hex-nespresso-insert.scad @@ -3,118 +3,26 @@ include $fn = 150; -// Overall pattern dimensions pattern_width = 375; // Total width of pattern (mm) pattern_height = 220; // Total height of pattern (mm) -pattern_thickness = 2; // Thickness of the entire pattern (mm) +pattern_thickness = 4; // Thickness of the entire pattern (mm) ring_inner_diameter = 38; // Inner diameter of rings (mm) ring_width = 2; // Width of ring walls (mm) -line_width = 2; // Width of connecting lines (mm) perimeter_width = 4; // Width of outer perimeter walls (mm) -hex_spacing = 45; // Distance between hex centers (mm) -ring_outer_radius = (ring_inner_diameter + 2 * ring_width) / 2; +ring_chamfer = 0.3*ring_width; -module hex_ring_pattern_2d() { - union() { - // Create outer rectangular perimeter using difference - difference() { - square([pattern_width, pattern_height], center=true); - square([pattern_width - 2*perimeter_width, pattern_height - 2*perimeter_width], center=true); - } - - // Get all valid ring positions - positions = get_hex_positions(); - - // Create rings at all valid positions - for (pos = positions) { - translate(pos) ring(r=ring_inner_diameter/2, ring_width=ring_width); - } - - // Create all connections - create_connections(positions); +module hex_insert() { + difference() { + cube([pattern_width,pattern_height,pattern_thickness], anchor=[0,0,-1]); + cube([pattern_width-2*perimeter_width,pattern_height-2*perimeter_width,pattern_thickness], anchor=[0,0,-1]); + } + + intersection() { + cube([pattern_width,pattern_height,pattern_thickness], anchor=[0,0,-1]); + grid_copies(size=[pattern_width,pattern_height], spacing=ring_inner_diameter+ring_width+ring_chamfer, stagger=true) + tube(id=ring_inner_diameter, wall=ring_width, h=pattern_thickness, ichamfer2=ring_chamfer, anchor=[0,0,-1]); } } -// Function to get all valid hexagonal ring positions -function get_hex_positions() = [ - for (row = [-8:8]) - for (col = [-10:10]) let( - x_pos = col * hex_spacing + (row % 2) * hex_spacing/2, - y_pos = row * hex_spacing * sin(60), - pos = [x_pos, y_pos] - ) - if (abs(x_pos) + ring_outer_radius <= pattern_width/2 && - abs(y_pos) + ring_outer_radius <= pattern_height/2) - pos -]; - -// Create all connections (hex grid + perimeter) -module create_connections(positions) { - if (len(positions) > 1) { - // Hex grid connections - for (i = [0:len(positions)-2]) { - for (j = [i+1:len(positions)-1]) { - pos1 = positions[i]; - pos2 = positions[j]; - dist = norm(pos2 - pos1); - - // Connect adjacent rings - if (dist > hex_spacing * 0.9 && dist < hex_spacing * 1.1) { - connect_rings(pos1, pos2); - } - } - } - - // Perimeter connections - for (pos = positions) { - connect_to_edges(pos); - } - } -} - -// Connect two rings with a line -module connect_rings(pos1, pos2) { - angle = atan2(pos2[1] - pos1[1], pos2[0] - pos1[0]); - start_point = pos1 + [cos(angle), sin(angle)] * (ring_inner_diameter/2); - end_point = pos2 - [cos(angle), sin(angle)] * (ring_inner_diameter/2); - - move((start_point + end_point)/2) - rot(angle) - square([norm(end_point - start_point), line_width], center=true); -} - -// Connect a ring to nearby perimeter edges -module connect_to_edges(pos) { - x = pos[0]; y = pos[1]; - half_w = pattern_width/2; half_h = pattern_height/2; - - // Connect to edges if ring is within 1.5 spacing units - if (x <= -half_w + hex_spacing * 1.5 && abs(y) <= half_h - perimeter_width) { - start = [x - ring_inner_diameter/2, y]; - end = [-half_w, y]; - move((start + end)/2) square([norm(end - start), line_width], center=true); - } - - if (x >= half_w - hex_spacing * 1.5 && abs(y) <= half_h - perimeter_width) { - start = [x + ring_inner_diameter/2, y]; - end = [half_w, y]; - move((start + end)/2) square([norm(end - start), line_width], center=true); - } - - if (y >= half_h - hex_spacing * 1.5 && abs(x) <= half_w - perimeter_width) { - start = [x, y + ring_inner_diameter/2]; - end = [x, half_h]; - move((start + end)/2) rot(90) square([norm(end - start), line_width], center=true); - } - - if (y <= -half_h + hex_spacing * 1.5 && abs(x) <= half_w - perimeter_width) { - start = [x, y - ring_inner_diameter/2]; - end = [x, -half_h]; - move((start + end)/2) rot(90) square([norm(end - start), line_width], center=true); - } -} - -linear_extrude(pattern_thickness) { - hex_ring_pattern_2d(); -} +hex_insert(); diff --git a/hex-nespresso-insert/hex-nespresso-insert.stl b/hex-nespresso-insert/hex-nespresso-insert.stl index b5370de..3682514 100644 Binary files a/hex-nespresso-insert/hex-nespresso-insert.stl and b/hex-nespresso-insert/hex-nespresso-insert.stl differ