From 32f91a77ca750f62b7680dbab61cd88d8496998c Mon Sep 17 00:00:00 2001 From: Arthur Moore Date: Sun, 21 Apr 2024 23:34:23 -0400 Subject: [PATCH] Support Chamfering Magnet Holes Similar to ljbeal's Pull Request. However, the implementation is completely different. https://github.com/kennetek/gridfinity-rebuilt-openscad/pull/144 --- gridfinity-rebuilt-holes.scad | 37 +++++++++++++++++++++++++++-------- standard.scad | 3 +++ 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/gridfinity-rebuilt-holes.scad b/gridfinity-rebuilt-holes.scad index 15ed318..73301ac 100644 --- a/gridfinity-rebuilt-holes.scad +++ b/gridfinity-rebuilt-holes.scad @@ -117,6 +117,28 @@ module refined_hole() { } } +/** + * @brief Create a cone given a radius and an angle. + * @param bottom_radius Radius of the bottom of the cone. + * @param angle Angle as measured from the bottom of the cone. + * @param max_height Optional maximum height. Cone will be cut off if higher. + */ +module cone(bottom_radius, angle, max_height=0) { + assert(bottom_radius > 0); + assert(angle > 0 && angle <= 90); + assert(max_height >=0); + + height = tan(angle) * bottom_radius; + if(max_height == 0 || height < max_height) { + // Normal Cone + cylinder(h = height, r1 = bottom_radius, r2 = 0, center = false); + } else { + top_angle = 90 - angle; + top_radius = bottom_radius - tan(top_angle) * max_height; + cylinder(h = max_height, r1 = bottom_radius, r2 = top_radius, center = false); + } +} + /** * @brief Create an options list used to configure bin holes. * @param refined_hole Use gridfinity refined hole type. Not compatible with "magnet_hole". @@ -148,7 +170,6 @@ module block_base_hole(hole_options, o=0) { if(refined_hole) { assert(!magnet_hole, "magnet_hole is not compatible with refined_hole"); } - assert(chamfer == false, "chamfer is not supported yet"); screw_radius = SCREW_HOLE_RADIUS - (o/2); magnet_radius = MAGNET_HOLE_RADIUS - (o/2); @@ -176,7 +197,7 @@ module block_base_hole(hole_options, o=0) { } if(chamfer) { - // Not Implemented Yet + cone(magnet_radius + MAGNET_HOLE_CHAMFER_ADDITIONAL_RADIUS, MAGNET_HOLE_CHAMFER_ANGLE, magnet_depth); } } @@ -189,10 +210,10 @@ module block_base_hole(hole_options, o=0) { //$fa = 8; //$fs = 0.25; //block_base_hole(bundle_hole_options( -// refined_hole=true, -// magnet_hole=false, -// screw_hole=false, -// supportless=false, -// crush_ribs=false, -// chamfer=false +// refined_hole=false, +// magnet_hole=true, +// screw_hole=true, +// supportless=true, +// crush_ribs=true, +// chamfer=true //)); diff --git a/standard.scad b/standard.scad index ff921fe..04bac18 100644 --- a/standard.scad +++ b/standard.scad @@ -50,6 +50,9 @@ 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 = 45; + // **************************************** // top edge fillet radius