Skip to content

Instantly share code, notes, and snippets.

@KOLANICH
Forked from groovenectar/roundedcube.scad
Last active May 26, 2022 19:53
Show Gist options
  • Save KOLANICH/2b24dfc9e49d772d914dae38e8d1c8d9 to your computer and use it in GitHub Desktop.
Save KOLANICH/2b24dfc9e49d772d914dae38e8d1c8d9 to your computer and use it in GitHub Desktop.
roundedcube.scad - Fork me and make me better!
// Set to 0.01 for higher definition curves (renders slower)
$fs = 0.15;
module cornerCut(sizeX, sizeY, size, r){
translate([sizeX-r, sizeY-r, 0]){
difference(){
translate([0, 0, -size/2]){
cube(size=[r, r, size]);
}
cylinder(h = size, r = r, center = true);
}
}
}
module twoCuts(sizeX, sizeY, size, r){
cornerCut(sizeX, sizeY, size, r);
mirror([0, 1, 0])
cornerCut(sizeX, sizeY, size, r);
}
module fourCuts(sizeX, sizeY, size, r){
twoCuts(sizeX, sizeY, size, r);
mirror([1, 0, 0])
twoCuts(sizeX, sizeY, size, r);
}
module roundedcube(size = [1, 1, 1], center = false, radius = [0.5, 0.5, 0.5], apply_to = "all") {
// If single value, convert to [x, y, z] vector
size = (size[0] == undef) ? [size, size, size] : size;
radius = (radius[0] == undef) ? [radius, radius, radius] : radius;
transl = (center == false) ? size/2 : [0, 0, 0];
translate(transl){
difference(){
cube(size=size, center=true);
union(){
if(radius[2] != 0)
fourCuts(size[0]/2, size[1]/2, size[2], radius[2]);
if(radius[0] != 0)
rotate([0, 90, 0])
fourCuts(size[2]/2, size[1]/2, size[0], radius[0]);
if(radius[1] != 0)
rotate([90, 0, 0])
fourCuts(size[0]/2, size[2]/2, size[1], radius[1]);
}
}
}
}
@groovenectar
Copy link

Since it is easy to do

I wouldn't have the same motivation since I have not printed in years, but I can see where it would be easy to do in some cases or at least easy to say it's easy to do :D I don't use GitHub for much personal stuff in the past few years either

I will go ahead and do it soon, really it wouldn't be too hard yes just some time spent. And maybe I'll just put a link to the new repo in the original file. Thanks again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment