/* http://codeviewer.org/view/code:1b36 Copyright (C) 2011 Sergio Vilches This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact: s.vilches.e@gmail.com ----------------------------------------------------------- Round Corners Cube (Extruded) roundCornersCube(x,y,z,r) Where: - x = Xdir width - y = Ydir width - z = Height of the cube - r = Rounding radious Example: roundCornerCube(10,10,2,1); *Some times it's needed to use F6 to see good results! ----------------------------------------------------------- */ // Test it! // roundCornersCube(10,5,2,1); module createMeniscus(h,radius) // This module creates the shape that needs to be substracted from a cube to make its corners rounded. difference(){ //This shape is basicly the difference between a quarter of cylinder and a cube translate([radius/2+0.1,radius/2+0.1,0]){ cube([radius+0.2,radius+0.1,h+0.2],center=true); // All that 0.x numbers are to avoid "ghost boundaries" when substracting } cylinder(h=h+0.2,r=radius,$fn = 25,center=true); } module roundCornersCube(x,y,z,r) // Now we just substract the shape we have created in the four corners difference(){ cube([x,y,z], center=true); translate([x/2-r,y/2-r]){ // We move to the first corner (x,y) rotate(0){ createMeniscus(z,r); // And substract the meniscus } } translate([-x/2+r,y/2-r]){ // To the second corner (-x,y) rotate(90){ createMeniscus(z,r); // But this time we have to rotate the meniscus 90 deg } } translate([-x/2+r,-y/2+r]){ // ... rotate(180){ createMeniscus(z,r); } } translate([x/2-r,-y/2+r]){ rotate(270){ createMeniscus(z,r); } } }