From 4d67b1a72516943ca95137dfd68c493e00aeb670 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Sat, 4 Jan 2020 21:37:38 -0600 Subject: [PATCH 1/3] Support center attribute so that polyhole behaves a bit more like cylinder() --- polyholes.scad | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/polyholes.scad b/polyholes.scad index 82edb5f..6603846 100644 --- a/polyholes.scad +++ b/polyholes.scad @@ -2,10 +2,10 @@ // This file is licensed under the terms of Creative Commons Attribution 3.0 Unported. // Using this holes should come out approximately right when printed -module polyhole(h, d) { +module polyhole(h, d, center=false) { n = max(round(2 * d),3); rotate([0,0,180]) - cylinder(h = h, r = (d / 2) / cos (180 / n), $fn = n); + cylinder(h = h, r = (d / 2) / cos (180 / n), $fn = n, center=center); } module test_polyhole(){ From f70e19e206c4b7c061ca84e99fa8d809a7731711 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Sat, 4 Jan 2020 21:46:08 -0600 Subject: [PATCH 2/3] Also accept radius or diameter for our polyholes. --- polyholes.scad | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/polyholes.scad b/polyholes.scad index 6603846..b61b8e1 100644 --- a/polyholes.scad +++ b/polyholes.scad @@ -2,10 +2,14 @@ // This file is licensed under the terms of Creative Commons Attribution 3.0 Unported. // Using this holes should come out approximately right when printed -module polyhole(h, d, center=false) { - n = max(round(2 * d),3); +module polyhole(h, r=0, d=0, center=false) { + _r = (r == 0 ? d / 2 : r); + _d = (d == 0 ? r * 2 : d); + + n = max(round(2 * _d),3); + rotate([0,0,180]) - cylinder(h = h, r = (d / 2) / cos (180 / n), $fn = n, center=center); + cylinder(h = h, r = (_d / 2) / cos (180 / n), $fn = n, center=center); } module test_polyhole(){ From bf2d04c279de48109a098874723733c8f6e60127 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Sat, 4 Jan 2020 21:48:38 -0600 Subject: [PATCH 3/3] Preserve original argument ordering --- polyholes.scad | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polyholes.scad b/polyholes.scad index b61b8e1..c433b8b 100644 --- a/polyholes.scad +++ b/polyholes.scad @@ -2,7 +2,7 @@ // This file is licensed under the terms of Creative Commons Attribution 3.0 Unported. // Using this holes should come out approximately right when printed -module polyhole(h, r=0, d=0, center=false) { +module polyhole(h, d=0, r=0, center=false) { _r = (r == 0 ? d / 2 : r); _d = (d == 0 ? r * 2 : d);