Skip to content

Instantly share code, notes, and snippets.

@mjparme
Last active September 15, 2021 19:29
Show Gist options
  • Select an option

  • Save mjparme/a16b053a11009ba0a676391a45100822 to your computer and use it in GitHub Desktop.

Select an option

Save mjparme/a16b053a11009ba0a676391a45100822 to your computer and use it in GitHub Desktop.
$fn = 100;
module roundedCube(length = 50, width = 40, height = 10, roundedRadius = 2) {
linear_extrude(height) roundedSquare(length = length, width = width, roundedRadius = roundedRadius);
}
//This is a 2d object
module roundedSquare(length = 50, width = 40, roundedRadius = 2) {
adjustedLength = length - roundedRadius;
adjustedWidth = width - roundedRadius;
hull() {
points = [[roundedRadius, roundedRadius], [adjustedLength, roundedRadius], [adjustedLength, adjustedWidth], [roundedRadius, adjustedWidth]];
for (point = points) {
translate(point) circle(roundedRadius);
}
}
}
//Test
length = 40;
roundedSquare(length = length);
translate([length + 5, 0, 0]) roundedCube(length = length);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment