Rounded corners in openScad

Someone on one of my youtube videos asked me "how to make rounded corners in openScad" and I thought my reply was helpful, so here it is!

If you want to make a square with rounded corners you'd have to make your own round_corner function. like this
module round_square(x,y,z,r){ hull(){ translate([r/2,r/2,0]) cylinder(h=z,d=r); translate([-(r/2)+x,r/2,0]) cylinder(h=z,d=r); translate([(r/2),-(r/2)+y,0]) cylinder(h=z,d=r); translate([(r/2)+x,(r/2)+y,0]) cylinder(h=z,d=r); } } round_square(20,20,20,5); If you wanted to make it in all of the directions for a cube you would do it like this module round_cube(x,y,z,r){ hull(){ translate([r/2,r/2,r/2]) sphere(d=r); translate([-(r/2)+x,r/2,r/2]) sphere(d=r); translate([(r/2),-(r/2)+y,r/2]) sphere(d=r); translate([(r/2)+(r/2)+y,r/2]) sphere(d=r); translate([r/2,r/2,-(r/2)+z]) sphere(d=r); translate([(r/2)+x,r/2,(r/2)+z]) sphere(d=r); translate([(r/2),(r/2)+y,(r/2)+z]) sphere(d=r); translate([(r/2)+x,(r/2)+y,-(r/2)+z]) sphere(d=r); } } round_cube(20,20,20,8); So in these example codes you can see the round_square and round_cube modules and the numbers inside of them thats kinda the same as putting in cube([xyz]) but you don't use an array and you do it like round_cube(x,y,z,r) r being the 4th (part I added) and that is the number to change how round you want the edges PS: if you want to do the same but with 2d parts it would be something like module round_square_2d(x,y,r){ hull(){ translate([r/2,r/2]) circle(d=r); translate([-(r/2)+x,r/2]) circle(d=r); translate([(r/2),-(r/2)+y]) circle(d=r); translate([(r/2)+x,(r/2)+y]) circle(d=r); } } round_square_2d(20,20,5); I hope all of that helps with whatever project you are working on, good luck!


Popular posts from this blog

m31 finger magnet rejection

Bluetooth LE bone conduction implant.