Is there an easy way/function to round edges for an openscad object?
6 Answers
minkowski()
is your friend for rounding over all edges of a geometry. minkowski()
is also incredibly slow and should only be used for final rendering. You can also implement primitives which have rounded edges more efficiently with other constructs.
$fn=60;
module drawLedgeRing()
{
difference()
{
cylinder(4,10,10);
translate([0,0,-1])
cylinder(4,6,6);
translate([0,0,2])
cylinder(4,8,8);
}
}
minkowski()
{
drawLedgeRing();
sphere(.25);
}
//drawLedgeRing();

- 1
- 1

- 1,147
- 9
- 11
I was looking for a radiused block to 3D print an instrument case. After reading the earlier answers I looked into hull making 8 identical spheres at the corners of a block and hulling them looks good:
module radiusedblock(xlen,ylen,zlen,radius){
hull(){
translate([radius,radius,radius]) sphere(r=radius);
translate([xlen + radius , radius , radius]) sphere(r=radius);
translate([radius , ylen + radius , radius]) sphere(r=radius);
translate([xlen + radius , ylen + radius , radius]) sphere(r=radius);
translate([radius , radius , zlen + radius]) sphere(r=radius);
translate([xlen + radius , radius , zlen + radius]) sphere(r=radius);
translate([radius,ylen + radius,zlen + radius]) sphere(r=radius);
translate([xlen + radius,ylen + radius,zlen + radius]) sphere(r=radius);
}
}
radiusedblock(30,40,50,5);

- 5,031
- 17
- 33
- 41

- 91
- 1
- 1
-
1This works, but your block is larger than intended. Rename to `radiusedblock_` and wrap it in this: `module radiusedblock(xlen,ylen,zlen,radius){ radiusedblock_(xlen-radius*2,ylen-radius*2,zlen-radius*2,radius); }`. – MightyPork May 21 '22 at 20:27
There are probably many ways to make a rounded cylinder. One way is to make 2 donut shaped objects and hull them
hull(){
rotate_extrude() translate([r1,0,0]) circle(r2);
rotate_extrude() translate([r1,0,h1]) circle(r2);
}

- 135
- 1
- 8
-
This gives "ERROR: all points for rotate_extrude() must have the same X coordinate sign (range is -0.81 -> 1.00) " – JBCP Jan 12 '23 at 03:51
-
@JBCP Not that it's likely to still be an issue for you, but the reason this would happen is if r1 is less than r2. Circles are centered on the origin by default, so the translate must move it over by at least as much as the circle's radius for rotate_extrude to work. – Rezer Mar 12 '23 at 21:26
To round a cylinder, you should use something like HULL command for two spheres.
It will make a tube where each sphere is the cap of the tube, by wrapping them into a new object.
You can use that to round your cylinder with minkowski.
minkowski between the cylinder and the rounded tube. If you merge a sphere with a cube, it will also round the long tube zone and make it pregnant. Hull is very useful, you can do 100ds of hull commands instead of an extrusion for complex stuff for example.
Also check Fibonaci sphere from thingiverse for an interesting sphere, although it isn't symmetrical as is best on a tube.

- 75
- 7
Try this cube with all sides rounded:
$fn=32;
border=5;
minkowski(){
cube([10,20,5],center=false);
rotate([90,0,90]) cylinder(h=10,r=border);
cylinder(h=0.1,r=border);
}

- 21
- 1
I needed the same thing today, and the answers here were only semi-useful, so I implemented my own module. Feel free to use/share :)
module roundedcube(xx, yy, height, radius) {
difference(){
cube([xx,yy,height]);
difference(){
translate([-.5,-.5,-.2])
cube([radius+.5,radius+.5,height+.5]);
translate([radius,radius,height/2])
cylinder(height,radius,radius,true);
}
translate([xx,0,0])
rotate(90)
difference(){
translate([-.5,-.5,-.2])
cube([radius+.5,radius+.5,height+.5]);
translate([radius,radius,height/2])
cylinder(height,radius,radius,true);
}
translate([xx,yy,0])
rotate(180)
difference(){
translate([-.5,-.5,-.2])
cube([radius+.5,radius+.5,height+.5]);
translate([radius,radius,height/2])
cylinder(height,radius,radius,true);
}
translate([0,yy,0])
rotate(270)
difference(){
translate([-.5,-.5,-.2])
cube([radius+.5,radius+.5,height+.5]);
translate([radius,radius,height/2])
cylinder(height,radius,radius,true);
}
}
}

- 913
- 8
- 24
-
3I created a gist with a simpler module to achieve the same result. Check out https://gist.github.com/tinkerology/ae257c5340a33ee2f149ff3ae97d9826 – Scott Leslie Feb 17 '20 at 05:57