mirror of
https://github.com/kennetek/gridfinity-rebuilt-openscad.git
synced 2024-12-22 23:03:28 +00:00
Simplify Hole Creation
Everything now goes through block_base_hole(...) Noting in gridfinity-rebuilt-utility knows or cares what sytle_hole contains.
This commit is contained in:
parent
a4200a04bd
commit
2e0e9bd363
2 changed files with 58 additions and 27 deletions
|
@ -37,24 +37,63 @@ module refined_hole() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
||||||
|
* @details
|
||||||
|
* - 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.
|
||||||
|
*/
|
||||||
module block_base_hole(style_hole, o=0) {
|
module block_base_hole(style_hole, o=0) {
|
||||||
r1 = SCREW_HOLE_RADIUS-o/2;
|
assert(style_hole >= 0 && style_hole <= 4, "Unhandled Hole Style");
|
||||||
r2 = MAGNET_HOLE_RADIUS-o/2;
|
|
||||||
union() {
|
|
||||||
difference() {
|
|
||||||
cylinder(h = 2*(MAGNET_HOLE_DEPTH-o+(style_hole==3?h_slit:0)), r=r2, center=true);
|
|
||||||
|
|
||||||
if (style_hole==3)
|
refined_hole = style_hole == 4;
|
||||||
copy_mirror([0,1,0])
|
magnet_hole = style_hole == 1 || style_hole == 2 || style_hole == 3;
|
||||||
translate([-1.5*r2,r1+0.1,MAGNET_HOLE_DEPTH-o])
|
screw_hole = style_hole == 2 || style_hole == 3;
|
||||||
cube([r2*3,r2*3, 10]);
|
crush_ribs = false; // Not Implemented Yet
|
||||||
|
chamfer = false; // Not Implemented Yet
|
||||||
|
supportless = style_hole==3;
|
||||||
|
|
||||||
|
screw_radius = SCREW_HOLE_RADIUS - (o/2);
|
||||||
|
magnet_radius = MAGNET_HOLE_RADIUS - (o/2);
|
||||||
|
// magnet_inner_radius = // Not Implemented Yet
|
||||||
|
screw_depth = h_base-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);
|
||||||
|
|
||||||
|
union() {
|
||||||
|
if(refined_hole) {
|
||||||
|
refined_hole();
|
||||||
|
}
|
||||||
|
if(magnet_hole) {
|
||||||
|
difference() {
|
||||||
|
if(crush_ribs){
|
||||||
|
// Not Implemented Yet
|
||||||
|
} else {
|
||||||
|
cylinder(h = magnet_depth, r=magnet_radius);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(supportless) {
|
||||||
|
copy_mirror([0,1,0])
|
||||||
|
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(screw_hole) {
|
||||||
|
cylinder(h = screw_depth, r = screw_radius);
|
||||||
}
|
}
|
||||||
if (style_hole > 1)
|
|
||||||
cylinder(h = 2*h_base-o, r = r1, center=true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//$fa = 8;
|
//$fa = 8;
|
||||||
//$fs = 0.25;
|
//$fs = 0.25;
|
||||||
//block_base_hole(0);
|
//block_base_hole(4);
|
||||||
//refined_hole();
|
|
||||||
|
|
|
@ -227,7 +227,7 @@ module gridfinityBase(gx, gy, l, dx, dy, style_hole, off=0, final_cut=true, only
|
||||||
translate([0,0,-1])
|
translate([0,0,-1])
|
||||||
rounded_rectangle(xx+0.005, yy+0.005, h_base+h_bot/2*10, r_fo1+0.001);
|
rounded_rectangle(xx+0.005, yy+0.005, h_base+h_bot/2*10, r_fo1+0.001);
|
||||||
|
|
||||||
if((style_hole != 0) && (only_corners)) {
|
if(only_corners) {
|
||||||
difference(){
|
difference(){
|
||||||
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, 0, off);
|
block_base(gx, gy, l, dbnx, dbny, 0, off);
|
||||||
|
@ -239,11 +239,7 @@ 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
|
||||||
])
|
])
|
||||||
if (style_hole == 4) {
|
block_base_hole(style_hole, off);
|
||||||
refined_hole();
|
|
||||||
}else {
|
|
||||||
block_base_hole(style_hole, off);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -270,14 +266,10 @@ module block_base(gx, gy, l, dbnx, dbny, style_hole, off) {
|
||||||
difference() {
|
difference() {
|
||||||
block_base_solid(dbnx, dbny, l, off);
|
block_base_solid(dbnx, dbny, l, off);
|
||||||
|
|
||||||
if (style_hole > 0)
|
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);
|
||||||
if (style_hole == 4)
|
}
|
||||||
refined_hole();
|
|
||||||
else
|
|
||||||
block_base_hole(style_hole, off);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue