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
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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]);
}
}
}
}
@KOLANICH
Copy link
Author

@groovenectar, could you pull this and move your stuff into a regular repo?

@groovenectar
Copy link

Hi @KOLANICH , sorry I'm only just now seeing this!! Your fork looks really good, you've made it a lot clearer...

I haven't been printing for years now... But you're right, putting it into a repo would be good.. there doesn't appear to be a merge flow with Gists.... I might be too late by now, but I'll start recommending your version to people if they ask, and let me know if you're still interested in the repo -- I know it's been a while

@groovenectar
Copy link

groovenectar commented May 26, 2022

It looks like it would be well worth integrating @ggs67's changes as well:

https://gist.github.com/ggs67/ff6ba8caf5a1871d285c5c758dce0575

And because of the way you cleaned it up, I think it'll be possible to combine both changes smoothly

@KOLANICH
Copy link
Author

let me know if you're still interested in the repo -- I know it's been a while

Having it in a PRable repo will benefit everyone. Since it is easy to do, it should just be done.

sorry I'm only just now seeing this!!

It's OK. It's opensource, noone owes anyone anything.

I might be too late by now

It's never too late.

@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