Skip to content

Cut arbitrary shapes into an indentation #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion gridfinity-rebuilt-bins.scad
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ cd = 10;
ch = 1;
// spacing to lid
c_depth = 1;
// fillet between indentation and walls
c_fillet = false;
// chamfer around the top rim of the holes
c_chamfer = 0.5;

Expand Down Expand Up @@ -95,7 +97,7 @@ gridfinityInit(gridx, gridy, height(gridz, gridz_define, style_lip, enable_zsnap

} else if (cdivx > 0 && cdivy > 0) {

cutCylinders(n_divx=cdivx, n_divy=cdivy, cylinder_diameter=cd, cylinder_height=ch, coutout_depth=c_depth, orientation=c_orientation, chamfer=c_chamfer);
cutCylinders(n_divx=cdivx, n_divy=cdivy, cylinder_diameter=cd, cylinder_height=ch, cutout_depth=c_depth, orientation=c_orientation, chamfer=c_chamfer,cutout_fillet=c_fillet);
}
}
gridfinityBase(gridx, gridy, l_grid, div_base_x, div_base_y, style_hole, only_corners=only_corners);
Expand Down Expand Up @@ -153,6 +155,30 @@ gridfinityInit(3, 3, height(6), 0, 42) {
gridfinityBase(3, 3, 42, 0, 0, 1);
*/

// Shapes can also be cut in an indentation by using cut_indent() instead of cut_move(). To cut multiple shapes into one indented compartment use indent() in combination with cut_move().
/*
gridfinityInit(2, 2, height(6), 0, 42) {

cut_indent(14, 0, 0, 1, 1, enable_fillet=false)
sphere(12);

indent(height(4), 1, 0, 1, 2) {
cut_move($indent_x, $indent_y, $indent_w, $indent_h/2) {
cube([20,20,20], true);
rotate([0,0,45]) cube([20,20,20], true);
}

cut_move($indent_x, $indent_y+1, $indent_w, $indent_h/2)
translate([0, 0, -10])
cylinder(20, r=12, true);
}

cut(0, 1, 1, 1);
}
gridfinityBase(2, 2, 42, 0, 0, 1);
//*/


// You can use loops as well as the bin dimensions to make different parametric functions, such as this one, which divides the box into columns, with a small 1x1 top compartment and a long vertical compartment below
/*
gx = 3;
Expand Down
66 changes: 51 additions & 15 deletions gridfinity-rebuilt-utility.scad
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ module cutEqual(n_divx=1, n_divy=1, style_tab=1, scoop_weight=1) {
// set n_div values to 0 for a solid bin
// cylinder_diameter: diameter of cutouts
// cylinder_height: height of cutouts
// coutout_depth: offset from top to solid part of container
// cutout_depth: offset from top to solid part of container
// orientation: orientation of cylinder cutouts (0 = x direction, 1 = y direction, 2 = z direction)
// chamfer: chamfer around the top rim of the holes
module cutCylinders(n_divx=1, n_divy=1, cylinder_diameter=1, cylinder_height=1, coutout_depth=0, orientation=0, chamfer=0.5) {
module cutCylinders(n_divx=1, n_divy=1, cylinder_diameter=1, cylinder_height=1, cutout_depth=0, orientation=0, chamfer=0.5, cutout_fillet=false) {
rotation = (orientation == 0)
? [0,90,0]
: (orientation == 1)
Expand All @@ -101,19 +101,15 @@ module cutCylinders(n_divx=1, n_divy=1, cylinder_diameter=1, cylinder_height=1,
cutout_x = gridx_mm - d_wall*2;
cutout_y = gridy_mm - d_wall*2;

cut_move(x=0, y=0, w=$gxx, h=$gyy) {
translate([0,0,-coutout_depth]) {
rounded_rectangle(cutout_x, cutout_y, coutout_depth*2, r_base);

pattern_linear(x=n_divx, y=n_divy, sx=(gridx_mm - padding)/n_divx, sy=(gridy_mm - padding)/n_divy)
rotate(rotation)
union() {
cylinder(d=cylinder_diameter, h=cylinder_height*2, center=true);
if (chamfer > 0) {
translate([0,0,-chamfer]) cylinder(d1=cylinder_diameter, d2=cylinder_diameter+4*chamfer, h=2*chamfer);
}
};
}
cut_indent(cutout_depth,x=0, y=0, w=$gxx, h=$gyy, enable_fillet=cutout_fillet) {
pattern_linear(x=n_divx, y=n_divy, sx=(gridx_mm - padding)/n_divx, sy=(gridy_mm - padding)/n_divy)
rotate(rotation)
union() {
cylinder(d=cylinder_diameter, h=cylinder_height*2, center=true);
if (chamfer > 0) {
translate([0,0,-chamfer]) cylinder(d1=cylinder_diameter, d2=cylinder_diameter+4*chamfer, h=2*chamfer);
}
};
}
}

Expand Down Expand Up @@ -196,6 +192,46 @@ module cut_move(x, y, w, h) {
children();
}


// Cuts an indentation at the requested compartment block and moves objects down to the new top surface height
// Use in conjunction with cut_move()
// d: indent depth
// x: start coord. x=0 is the left side of the bin.
// y: start coord. y=0 is the bottom side of the bin.
// w: width of compartment, in # of bases covered
// h: height of compartment, in # of bases covered
// enable_fillet: add a fillet between the surface of the indentation and the wall
module indent(d, x = 0, y = 0, w = $gxx, h = $gyy, enable_fillet = true) {

$indent_d = d;
$indent_x = x;
$indent_y = y;
$indent_w = w;
$indent_h = h;

grid_to_mm = l_grid - d_wall*2;

translate([0, 0, -d]) {
if (enable_fillet)
translate([0, 0, $dh - h_bot])
cut(x, y, w, h, t=5, s=0);
else
cut_move(x, y, w, h)
rounded_rectangle(w*grid_to_mm, h*grid_to_mm, d*2, r_f2);

children();
}
}

// Cuts an indentation at the requested compartment and translates objects from the origin point to the center of the indentation. Combines indent() and cut_move().
// See indent() module for parameter descriptions
module cut_indent(d, x = 0, y = 0, w = $gxx, h = $gyy, enable_fillet = true) {
indent(d, x, y, w, h, enable_fillet)
cut_move(x, y, w, h)
children();
}


// ===== Modules ===== //

module profile_base() {
Expand Down