Allow mixing and matching hole options.

This commit is contained in:
Arthur Moore 2024-04-15 01:05:46 -04:00
parent f2a8e20c20
commit e9d33d7ad4
4 changed files with 85 additions and 68 deletions

View file

@ -72,19 +72,30 @@ style_tab = 1; //[0:Full,1:Auto,2:Left,3:Center,4:Right,5:None]
style_lip = 0; //[0: Regular lip, 1:remove lip subtractively, 2: remove lip and retain height]
// scoop weight percentage. 0 disables scoop, 1 is regular scoop. Any real number will scale the scoop.
scoop = 1; //[0:0.1:1]
// only cut magnet/screw holes at the corners of the bin to save uneccesary print time
only_corners = false;
// chamfer out magnet holes for easier magnet insertion. Set to 0 to disable chamfer
hole_chamfer = 0.8;
/* [Base] */
style_hole = 4; // [0:no holes, 1:magnet holes only, 2: magnet and screw holes - no printable slit, 3: magnet and screw holes - printable slit, 4: Gridfinity Refined hole - no glue needed, 5: Magnet hole with crush ribs]
// number of divisions per 1 unit of base along the X axis. (default 1, only use integers. 0 means automatically guess the right division)
div_base_x = 0;
// number of divisions per 1 unit of base along the Y axis. (default 1, only use integers. 0 means automatically guess the right division)
div_base_y = 0;
/* [Base Hole Options] */
// only cut magnet/screw holes at the corners of the bin to save uneccesary print time
only_corners = false;
//Use gridfinity refined hole style. Not compatible with magnet_holes!
refined_hole = true;
// Base will have holes for 6mm Diameter x 2mm high magnets.
magnet_holes = false;
// Base will have holes for M3 screws.
screw_holes = false;
// Magnet holes will have crush ribs to hold the magnet.
crush_ribs = false;
// Magnet holes will have a chamfer to ease insertion.
chamfer_magnet_holes = false;
// Allows printing screw holes with magnet holes without using supports.
printable_magnet_hole_top = false;
hole_options = bundle_hole_options(refined_hole, magnet_holes, screw_holes, crush_ribs, chamfer_magnet_holes, printable_magnet_hole_top);
// ===== IMPLEMENTATION ===== //
@ -100,7 +111,7 @@ gridfinityInit(gridx, gridy, height(gridz, gridz_define, style_lip, enable_zsnap
cutCylinders(n_divx=cdivx, n_divy=cdivy, cylinder_diameter=cd, cylinder_height=ch, coutout_depth=c_depth, orientation=c_orientation, chamfer=c_chamfer);
}
}
gridfinityBase(gridx, gridy, l_grid, div_base_x, div_base_y, style_hole, only_corners=only_corners, hole_chamfer=hole_chamfer);
gridfinityBase(gridx, gridy, l_grid, div_base_x, div_base_y, hole_options, only_corners=only_corners);
}

View file

@ -70,41 +70,22 @@ module ribbed_cylinder(outer_radius, inner_radius, height, ribs) {
}
/**
* @brief A single magnet and screw hole.
* @param screw_radius Radius of the screw hole.
* @param magnet_radius Radius of the magnet hole.
* @param screw_depth Depth of the screw hole.
* @param magnet_depth Depth of the magnet hole.
* @details This is the negative designed to be cut out of the base.
*/
module magnet_and_screw_hole(screw_radius, magnet_radius, screw_depth, magnet_depth) {
union() {
cylinder(h = magnet_depth, r=magnet_radius);
cylinder(h = screw_depth, r = screw_radius);
}
}
/**
* @brief A single magnet and screw hole, designed to be printed without supports.
* @brief Make a magnet hole printable without suports.
* @see https://www.youtube.com/watch?v=W8FbHTcB05w
* @param screw_radius Radius of the screw hole.
* @param magnet_radius Radius of the magnet hole.
* @param screw_depth Depth of the screw hole.
* @param magnet_depth Depth of the magnet hole.
* @details This is the negative designed to be cut out of the base.
* @details This is the negative designed to be cut out of the magnet hole.
* Use it with `difference()`.
*/
module magnet_and_screw_hole_printable(screw_radius, magnet_radius, screw_depth, magnet_depth) {
difference() {
magnet_and_screw_hole(screw_radius, magnet_radius, screw_depth, magnet_depth + LAYER_HEIGHT);
translate([-1.5*magnet_radius, screw_radius+0.1, magnet_depth])
module make_magnet_hole_printable(screw_radius, magnet_radius, magnet_depth) {
translate([-1.5*magnet_radius, screw_radius+0.1, magnet_depth - LAYER_HEIGHT])
cube([magnet_radius*3, magnet_radius*3, 10]);
// Equivalent to copy_mirror([0,1,0])
mirror([0,1,0])
translate([-1.5*magnet_radius, screw_radius+0.1, magnet_depth])
translate([-1.5*magnet_radius, screw_radius+0.1, magnet_depth - LAYER_HEIGHT])
cube([magnet_radius*3, magnet_radius*3, 10]);
}
}
/**
@ -160,46 +141,71 @@ module cone(bottom_radius, angle, max_height=0) {
}
/**
* @brief A single magnet/screw hole. To be cut out of the base.
* @pram style_hole Determines the type of hole that will be generated.
* @param o Offset
* @param chamfer Optional Chamfer added to all but refined holed to make magnet insertion easier.
* @details
* Just calls the appropriate function with an offset from the constants.
* - 0: No holes. Does nothing.
* - 1: Magnet holes only
* - 2: Magnet and screw holes - no printable slit.
* - 3: Magnet and screw holes - printable slit.
* - 4: Gridfinity Refined hole - no glue needed.
* - 5: Magnet hole with crush ribs.
* @brief Create an options list used to configure bin holes.
* @param refined_hole Use gridfinity refined hole type. Not compatible with "magnet_hole".
* @param magnet_hole Create a hole for a 6mm magnet.
* @param screw_hole Create a hole for a M3 screw.
* @param crush_ribs If the magnet hole should have crush ribs for a press fit.
* @param chamfer Add a chamfer to the magnet hole.
* @param supportless If the magnet hole should be printed in such a way that the screw hole does not require supports.
*/
module block_base_hole(style_hole, o=0, chamfer=0) {
assert(style_hole >= 0 && style_hole <= 5, "Unhandled Hole Style");
assert(chamfer >= 0, "chamfer may not be negative");
function bundle_hole_options(refined_hole=true, magnet_hole=false, screw_hole=false, crush_ribs=false, chamfer=false, supportless=false) =
[refined_hole, magnet_hole, screw_hole, crush_ribs, chamfer, supportless];
/**
* @brief A single magnet/screw hole. To be cut out of the base.
* @details Supports multiple options that can be mixed and matched.
* @pram hole_options @see bundle_hole_options
* @param o Offset
*/
module block_base_hole(hole_options, o=0) {
// Destructure the options
refined_hole = hole_options[0];
magnet_hole = hole_options[1];
screw_hole = hole_options[2];
crush_ribs = hole_options[3];
chamfer = hole_options[4];
supportless = hole_options[5];
// Validate said options
if(refined_hole) {
assert(!magnet_hole, "magnet_hole is not compatible with refined_hole");
}
screw_radius = SCREW_HOLE_RADIUS - (o/2);
magnet_radius = MAGNET_HOLE_RADIUS - (o/2);
magnet_inner_radius = MAGNET_HOLE_CRUSH_RIB_INNER_RADIUS - (o/2);
screw_depth = h_base-o;
magnet_depth = MAGNET_HOLE_DEPTH - o;
// If using supportless / printable mode, need to add an additional layer, so it can be removed later
magnet_depth = MAGNET_HOLE_DEPTH - o + (supportless ? LAYER_HEIGHT : 0);
if (style_hole == 1) {
cylinder(h = magnet_depth, r=magnet_radius);
}
if (style_hole == 2) {
magnet_and_screw_hole(screw_radius, magnet_radius, screw_depth, magnet_depth);
}
if (style_hole==3) {
magnet_and_screw_hole_printable(screw_radius, magnet_radius, screw_depth, magnet_depth);
}
if (style_hole==4) {
union() {
if(refined_hole) {
refined_hole();
}
if (style_hole == 5) {
ribbed_cylinder(magnet_radius, magnet_inner_radius, magnet_depth, MAGNET_HOLE_CRUSH_RIB_COUNT);
if(magnet_hole) {
difference() {
if(crush_ribs) {
ribbed_cylinder(magnet_radius, magnet_inner_radius, magnet_depth, MAGNET_HOLE_CRUSH_RIB_COUNT);
} else {
cylinder(h = magnet_depth, r=magnet_radius);
}
if(supportless) {
make_magnet_hole_printable(screw_radius, magnet_radius, magnet_depth);
}
}
if(chamfer) {
cone(magnet_radius + MAGNET_HOLE_CHAMFER_ADDITIONAL_RADIUS, MAGNET_HOLE_CHAMFER_ANGLE, magnet_depth);
}
}
if(screw_hole) {
cylinder(h = screw_depth, r = screw_radius);
}
if (chamfer > 0 && style_hole != 0 && style_hole != 4) {
cone(magnet_radius + chamfer, MAGNET_HOLE_CHAMFER_ANGLE, magnet_depth);
}
}

View file

@ -211,7 +211,7 @@ module profile_base() {
]);
}
module gridfinityBase(gx, gy, l, dx, dy, style_hole, off=0, final_cut=true, only_corners=false, hole_chamfer=0.0) {
module gridfinityBase(gx, gy, l, dx, dy, hole_options, off=0, final_cut=true, only_corners=false) {
dbnxt = [for (i=[1:5]) if (abs(gx*i)%1 < 0.001 || abs(gx*i)%1 > 0.999) i];
dbnyt = [for (i=[1:5]) if (abs(gy*i)%1 < 0.001 || abs(gy*i)%1 > 0.999) i];
dbnx = 1/(dx==0 ? len(dbnxt) > 0 ? dbnxt[0] : 1 : round(dx));
@ -240,14 +240,14 @@ module gridfinityBase(gx, gy, l, dx, dy, style_hole, off=0, final_cut=true, only
(gy/2) * l_grid - d_hole_from_side,
0
])
block_base_hole(style_hole, off, hole_chamfer);
block_base_hole(hole_options, off);
}
}
}
}
else {
pattern_linear(gx/dbnx, gy/dbny, dbnx*l, dbny*l)
block_base(gx, gy, l, dbnx, dbny, style_hole, off, hole_chamfer);
block_base(gx, gy, l, dbnx, dbny, hole_options, off);
}
}
}
@ -259,18 +259,17 @@ module gridfinityBase(gx, gy, l, dx, dy, style_hole, off=0, final_cut=true, only
* @param l
* @param dbnx
* @param dbny
* @param style_hole @see block_base_hole.style_hole
* @param hole_options @see block_base_hole.hole_options
* @param off
* @param hole_chamfer Chamfer for magnet holes. Set to 0 to disable.
*/
module block_base(gx, gy, l, dbnx, dbny, style_hole, off, hole_chamfer) {
module block_base(gx, gy, l, dbnx, dbny, hole_options, off) {
render(convexity = 2)
difference() {
block_base_solid(dbnx, dbny, l, off);
pattern_circular(abs(l-d_hole_from_side/2)<0.001?1:4)
translate([l/2-d_hole_from_side, l/2-d_hole_from_side, 0])
block_base_hole(style_hole, off, hole_chamfer);
block_base_hole(hole_options, off);
}
}

View file

@ -47,6 +47,7 @@ MAGNET_HOLE_CRUSH_RIB_INNER_RADIUS = 5.9 / 2;
// Anything 5 or under produces a hole that is not round.
MAGNET_HOLE_CRUSH_RIB_COUNT = 8;
MAGNET_HOLE_CHAMFER_ADDITIONAL_RADIUS = 0.8;
MAGNET_HOLE_CHAMFER_ANGLE = 50;
// ****************************************