mirror of
https://github.com/kennetek/gridfinity-rebuilt-openscad.git
synced 2024-12-22 14:53:25 +00:00
Allow mixing and matching hole options
This commit is contained in:
parent
2e0e9bd363
commit
8fa885ac72
3 changed files with 83 additions and 35 deletions
|
@ -72,17 +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]
|
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 weight percentage. 0 disables scoop, 1 is regular scoop. Any real number will scale the scoop.
|
||||||
scoop = 1; //[0:0.1:1]
|
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;
|
|
||||||
|
|
||||||
/* [Base] */
|
/* [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]
|
|
||||||
// number of divisions per 1 unit of base along the X axis. (default 1, only use integers. 0 means automatically guess the right division)
|
// 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;
|
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)
|
// 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;
|
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 ===== //
|
// ===== IMPLEMENTATION ===== //
|
||||||
|
|
||||||
|
@ -98,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);
|
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);
|
gridfinityBase(gridx, gridy, l_grid, div_base_x, div_base_y, hole_options, only_corners=only_corners);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,22 @@
|
||||||
include <standard.scad>
|
include <standard.scad>
|
||||||
use <generic-helpers.scad>
|
use <generic-helpers.scad>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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 magnet_depth Depth of the magnet hole.
|
||||||
|
* @details This is the negative designed to be cut out of the magnet hole.
|
||||||
|
* Use it with `difference()`.
|
||||||
|
*/
|
||||||
|
module make_magnet_hole_printable(screw_radius, magnet_radius, magnet_depth) {
|
||||||
|
copy_mirror([0,1,0]) {
|
||||||
|
translate([-1.5*magnet_radius, screw_radius+0.1, magnet_depth - LAYER_HEIGHT])
|
||||||
|
cube([magnet_radius*3, magnet_radius*3, 10]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Refined hole based on Printables @grizzie17's Gridfinity Refined
|
* @brief Refined hole based on Printables @grizzie17's Gridfinity Refined
|
||||||
* @details Magnet is pushed in from +X direction, and held in by friction.
|
* @details Magnet is pushed in from +X direction, and held in by friction.
|
||||||
|
@ -38,25 +54,37 @@ module refined_hole() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A single magnet/screw hole. To be cut out of the base.
|
* @brief Create an options list used to configure bin holes.
|
||||||
* @pram style_hole Determines the type of hole that will be generated.
|
* @param refined_hole Use gridfinity refined hole type. Not compatible with "magnet_hole".
|
||||||
* @param o Offset
|
* @param magnet_hole Create a hole for a 6mm magnet.
|
||||||
* @details
|
* @param screw_hole Create a hole for a M3 screw.
|
||||||
* - 0: No holes. Does nothing.
|
* @param crush_ribs If the magnet hole should have crush ribs for a press fit.
|
||||||
* - 1: Magnet holes only
|
* @param chamfer Add a chamfer to the magnet hole.
|
||||||
* - 2: Magnet and screw holes - no printable slit.
|
* @param supportless If the magnet hole should be printed in such a way that the screw hole does not require supports.
|
||||||
* - 3: Magnet and screw holes - printable slit.
|
|
||||||
* - 4: Gridfinity Refined hole - no glue needed.
|
|
||||||
*/
|
*/
|
||||||
module block_base_hole(style_hole, o=0) {
|
function bundle_hole_options(refined_hole=true, magnet_hole=false, screw_hole=false, crush_ribs=false, chamfer=false, supportless=false) =
|
||||||
assert(style_hole >= 0 && style_hole <= 4, "Unhandled Hole Style");
|
[refined_hole, magnet_hole, screw_hole, crush_ribs, chamfer, supportless];
|
||||||
|
|
||||||
refined_hole = style_hole == 4;
|
/**
|
||||||
magnet_hole = style_hole == 1 || style_hole == 2 || style_hole == 3;
|
* @brief A single magnet/screw hole. To be cut out of the base.
|
||||||
screw_hole = style_hole == 2 || style_hole == 3;
|
* @details Supports multiple options that can be mixed and matched.
|
||||||
crush_ribs = false; // Not Implemented Yet
|
* @pram hole_options @see bundle_hole_options
|
||||||
chamfer = false; // Not Implemented Yet
|
* @param o Offset
|
||||||
supportless = style_hole==3;
|
*/
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
assert(crush_ribs == false && chamfer == false, "crush_ribs and chamfer are not supported yet");
|
||||||
|
|
||||||
screw_radius = SCREW_HOLE_RADIUS - (o/2);
|
screw_radius = SCREW_HOLE_RADIUS - (o/2);
|
||||||
magnet_radius = MAGNET_HOLE_RADIUS - (o/2);
|
magnet_radius = MAGNET_HOLE_RADIUS - (o/2);
|
||||||
|
@ -69,23 +97,23 @@ module block_base_hole(style_hole, o=0) {
|
||||||
if(refined_hole) {
|
if(refined_hole) {
|
||||||
refined_hole();
|
refined_hole();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(magnet_hole) {
|
if(magnet_hole) {
|
||||||
difference() {
|
difference() {
|
||||||
if(crush_ribs){
|
if(crush_ribs) {
|
||||||
// Not Implemented Yet
|
// Not Implemented Yet
|
||||||
} else {
|
} else {
|
||||||
cylinder(h = magnet_depth, r=magnet_radius);
|
cylinder(h = magnet_depth, r=magnet_radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(supportless) {
|
if(supportless) {
|
||||||
copy_mirror([0,1,0])
|
make_magnet_hole_printable(screw_radius, magnet_radius, magnet_depth);
|
||||||
translate([-1.5*magnet_radius, screw_radius+0.1,magnet_depth])
|
|
||||||
cube([magnet_radius*3,magnet_radius*3, 10]);
|
|
||||||
}
|
|
||||||
if(chamfer) {
|
|
||||||
// Not Implemented Yet
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(chamfer) {
|
||||||
|
// Not Implemented Yet
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(screw_hole) {
|
if(screw_hole) {
|
||||||
|
@ -96,4 +124,11 @@ module block_base_hole(style_hole, o=0) {
|
||||||
|
|
||||||
//$fa = 8;
|
//$fa = 8;
|
||||||
//$fs = 0.25;
|
//$fs = 0.25;
|
||||||
//block_base_hole(4);
|
//block_base_hole(bundle_hole_options(
|
||||||
|
// refined_hole=true,
|
||||||
|
// magnet_hole=false,
|
||||||
|
// screw_hole=false,
|
||||||
|
// supportless=false,
|
||||||
|
// crush_ribs=false,
|
||||||
|
// chamfer=false
|
||||||
|
//));
|
||||||
|
|
|
@ -210,7 +210,7 @@ module profile_base() {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
module gridfinityBase(gx, gy, l, dx, dy, style_hole, off=0, final_cut=true, only_corners=false) {
|
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];
|
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];
|
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));
|
dbnx = 1/(dx==0 ? len(dbnxt) > 0 ? dbnxt[0] : 1 : round(dx));
|
||||||
|
@ -239,14 +239,14 @@ module gridfinityBase(gx, gy, l, dx, dy, style_hole, off=0, final_cut=true, only
|
||||||
(gy/2) * l_grid - d_hole_from_side,
|
(gy/2) * l_grid - d_hole_from_side,
|
||||||
0
|
0
|
||||||
])
|
])
|
||||||
block_base_hole(style_hole, off);
|
block_base_hole(hole_options, off);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pattern_linear(gx/dbnx, gy/dbny, dbnx*l, dbny*l)
|
pattern_linear(gx/dbnx, gy/dbny, dbnx*l, dbny*l)
|
||||||
block_base(gx, gy, l, dbnx, dbny, style_hole, off);
|
block_base(gx, gy, l, dbnx, dbny, hole_options, off);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,17 +258,17 @@ module gridfinityBase(gx, gy, l, dx, dy, style_hole, off=0, final_cut=true, only
|
||||||
* @param l
|
* @param l
|
||||||
* @param dbnx
|
* @param dbnx
|
||||||
* @param dbny
|
* @param dbny
|
||||||
* @param style_hole @see block_base_hole.style_hole
|
* @param hole_options @see block_base_hole.hole_options
|
||||||
* @param off
|
* @param off
|
||||||
*/
|
*/
|
||||||
module block_base(gx, gy, l, dbnx, dbny, style_hole, off) {
|
module block_base(gx, gy, l, dbnx, dbny, hole_options, off) {
|
||||||
render(convexity = 2)
|
render(convexity = 2)
|
||||||
difference() {
|
difference() {
|
||||||
block_base_solid(dbnx, dbny, l, off);
|
block_base_solid(dbnx, dbny, l, off);
|
||||||
|
|
||||||
pattern_circular(abs(l-d_hole_from_side/2)<0.001?1:4)
|
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])
|
translate([l/2-d_hole_from_side, l/2-d_hole_from_side, 0])
|
||||||
block_base_hole(style_hole, off);
|
block_base_hole(hole_options, off);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue