2 http://codeviewer.org/view/code:1b36
3 Copyright (C) 2011 Sergio Vilches
4 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.
5 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 <http://www.gnu.org/licenses/>.
6 Contact: s.vilches.e@gmail.com
9 -----------------------------------------------------------
10 Round Corners Cube (Extruded)
11 roundCornersCube(x,y,z,r) Where:
14 - z = Height of the cube
15 - r = Rounding radious
17 Example: roundCornerCube(10,10,2,1);
18 *Some times it's needed to use F6 to see good results!
19 -----------------------------------------------------------
22 // roundCornersCube(10,5,2,1);
25 module createMeniscus(h,radius) // This module creates the shape that needs to be substracted from a cube to make its corners rounded.
26 difference(){ //This shape is basicly the difference between a quarter of cylinder and a cube
27 translate([radius/2+0.1,radius/2+0.1,0]){
28 cube([radius+0.2,radius+0.1,h+0.2],center=true); // All that 0.x numbers are to avoid "ghost boundaries" when substracting
31 cylinder(h=h+0.2,r=radius,$fn = 25,center=true);
35 module roundCornersCube(x,y,z,r) // Now we just substract the shape we have created in the four corners
37 cube([x,y,z], center=true);
39 translate([x/2-r,y/2-r]){ // We move to the first corner (x,y)
41 createMeniscus(z,r); // And substract the meniscus
44 translate([-x/2+r,y/2-r]){ // To the second corner (-x,y)
46 createMeniscus(z,r); // But this time we have to rotate the meniscus 90 deg
49 translate([-x/2+r,-y/2+r]){ // ...
54 translate([x/2-r,-y/2+r]){