Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/haydnhuntley/kumu-3d.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaydn Huntley <haydn.huntley@gmail.com>2017-03-27 03:37:23 +0300
committerGitHub <noreply@github.com>2017-03-27 03:37:23 +0300
commitb2c19379b3569e82f97681a8a0f4881fd60700fb (patch)
tree761ddfe3a7d2a48011695288ad9b5699f789b4b7
parentcba6c410451f5be23897aefc28a4efae42bbcfde (diff)
Added roundedBox.scad
-rw-r--r--roundedBox.scad46
1 files changed, 46 insertions, 0 deletions
diff --git a/roundedBox.scad b/roundedBox.scad
new file mode 100644
index 0000000..b2634ae
--- /dev/null
+++ b/roundedBox.scad
@@ -0,0 +1,46 @@
+// size is a vector [x, y, z], always draws from center!
+module roundedBox(size, radius=5, sidesonly=true)
+{
+ rot = [ [0,0,0], [90,0,90], [90,90,0] ];
+ if (sidesonly)
+ {
+ cube(size - [2*radius,0,0], true);
+ cube(size - [0,2*radius,0], true);
+ for (x = [radius-size[0]/2, -radius+size[0]/2],
+ y = [radius-size[1]/2, -radius+size[1]/2])
+ {
+ translate([x,y,0])
+ cylinder(r=radius, h=size[2], center=true);
+ }
+ }
+ else
+ {
+ cube([size[0], size[1]-radius*2, size[2]-radius*2],
+ center=true);
+ cube([size[0]-radius*2, size[1], size[2]-radius*2],
+ center=true);
+ cube([size[0]-radius*2, size[1]-radius*2, size[2]],
+ center=true);
+
+ for (axis = [0:2])
+ {
+ for (x = [radius-size[axis]/2, -radius+size[axis]/2],
+ y = [ radius-size[(axis+1)%3]/2,
+ -radius+size[(axis+1)%3]/2])
+ {
+ rotate(rot[axis])
+ translate([x,y,0])
+ cylinder(h=size[(axis+2)%3]-2*radius,
+ r=radius, center=true);
+ }
+ }
+ for (x = [radius-size[0]/2, -radius+size[0]/2],
+ y = [radius-size[1]/2, -radius+size[1]/2],
+ z = [radius-size[2]/2, -radius+size[2]/2])
+ {
+ translate([x,y,z])
+ sphere(radius);
+ }
+ }
+}
+