Skip to content

Instantly share code, notes, and snippets.

@hyperair
Created December 18, 2014 06:16
Show Gist options
  • Select an option

  • Save hyperair/e0636ea97f30b86d8fcf to your computer and use it in GitHub Desktop.

Select an option

Save hyperair/e0636ea97f30b86d8fcf to your computer and use it in GitHub Desktop.
// Author: Marius Kintel
// Copyright: 2010
// License: 2-clause BSD License (http://opensource.org/licenses/BSD-2-Clause)
// mcad_rounded_box([width, height, depth], float radius, bool sidesonly);
// EXAMPLE USAGE:
// mcad_rounded_box([20, 30, 40], 5, true);
// size is a vector [w, h, d]
module mcad_rounded_box (size, radius, sidesonly)
{
module place_xy ()
for (x = [size[0]/2 - radius, -size[0]/2 + radius])
for (y = [size[1]/2 - radius, -size[1]/2 + radius])
translate ([x, y, 0])
children ();
hull ()
if (sidesonly) {
place_xy ()
cylinder (r = radius, h = size[2], center=true);
} else {
for (z = [size[2]/2 - radius, -size[2]/2 + radius])
translate ([0, 0, z])
place_xy ()
sphere (r = radius);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment