Everything built so far in this series has had hard corners. That is fine for a cup, but it is rarely what you want for something that gets handled, stacked or loaded. Sharp inside corners are where printed parts tend to crack first, and square outside corners catch on everything. Rounding them is one of the cheapest improvements you can make to a design.
OpenSCAD has two tools for it, and they work in very different ways.
hull(): stretch a skin over everything inside
hull() takes whatever you put inside it and wraps the tightest possible convex skin around the lot. Think of shrink-wrap, or an elastic band stretched round a set of pegs. Four cylinders standing at the corners of a rectangle, wrapped in a hull, become a rectangular block with rounded corners:
module rounded_box(w, l, h, r = 5) {
assert(r > 0 && 2*r <= min(w, l),
str("r is ", r, "mm; it must be positive and no more than half of the shorter side (", min(w, l), "mm)"));
hull()
for (x = [r, w - r], y = [r, l - r])
translate([x, y, 0])
cylinder(r = r, h = h, $fn = 48);
}Two things are worth noticing. The loop for (x = [r, w - r], y = [r, l - r]) has two variables, and OpenSCAD runs it for every combination of them, which gives exactly the four corners. And the cylinders sit at r in from each edge, so their outer surfaces land precisely on the edges of the w by l footprint. The box is the size you asked for, not a size plus a bit.
The assert is Part 5 at work. A corner radius larger than half the shorter side cannot fit, and without the guard OpenSCAD would quietly give you something that is not what you asked for.
Rounding the inside too
A rounded box becomes a useful object when you hollow it out. The obvious way is to subtract a smaller rounded box from a larger one, and there is one detail that makes it look right or wrong:
module tray(w = 100, l = 60, h = 25, r = 8, wall = 2.4, floor_t = 2.4) {
assert(r > wall,
str("r is ", r, "mm; it must exceed wall (", wall, "mm) so the inside corners stay rounded"));
assert(h > floor_t,
str("h is ", h, "mm; it must exceed floor_t (", floor_t, "mm) or there is no cavity"));
difference() {
rounded_box(w, l, h, r);
translate([wall, wall, floor_t])
rounded_box(w - 2*wall, l - 2*wall, h, r - wall);
}
}The inner box is given a radius of r - wall, not r. Concentric curves a wall's thickness apart give a wall of even thickness all the way round the corner. Use the same radius on both and the wall pinches thin at every corner, which is exactly where you wanted strength. That is also why the second assert insists that r exceeds wall: otherwise the inner radius would be zero or negative.

minkowski(): slide one shape over the surface of another
minkowski() does something stranger. It takes two shapes and moves one around the surface of the other, and the volume it sweeps out is the result. Slide a small sphere over every face, edge and corner of a cube and you get a block with every edge and every corner rounded, not only the vertical ones.
module soft_block(w, l, h, r = 3) {
assert(r > 0 && 2*r < min(w, l, h),
str("r is ", r, "mm; it must be positive and less than half of the smallest side (", min(w, l, h), "mm)"));
translate([r, r, r])
minkowski() {
cube([w - 2*r, l - 2*r, h - 2*r]);
sphere(r = r, $fn = 24);
}
}There is a bookkeeping rule here that catches everyone once. The result is bigger than the cube by the sphere's radius on every side. To get a block of exactly w by l by h you shrink the cube by 2*r in each direction, then shift the whole thing by r so it sits where you expect. Skip either step and your design quietly changes size.
Even then, do not expect a perfect number. The sphere is made of flat facets like everything else, and at 24 facets it does not quite reach its full radius everywhere. The 40mm block here measures about 39.9mm. Raising $fn closes the gap at the price of a slower render, which is the same trade between smooth curves and file size that the dimensional accuracy post met on the printer side.
Where hull() fills in, and minkowski() gets slow
hull() only ever produces convex shapes. Anything that curves inwards gets filled in, including holes. Hull a ring and you get a solid disc. So the order matters: build the outside with hull(), then cut holes and cavities afterwards with difference(), as the tray does. The same idea shows up in a tapered link between two different circles:
module link(spacing = 40, big_d = 20, small_d = 12, t = 5) {
hull() {
cylinder(d = big_d, h = t, $fn = 48);
translate([spacing, 0, 0])
cylinder(d = small_d, h = t, $fn = 48);
}
}A hull of two circles of different sizes gives the classic tapered shape, in a few lines. If you want holes through each end, subtract them after the hull, not before.
minkowski() has a cost the other tools do not. It is quick when both shapes are simple and convex, and it can become painfully slow when one of them is a complicated, hollow or many-faceted shape. If a preview that used to take a second suddenly takes minutes, a minkowski() with a detailed shape inside it is the first place to look.

Which to reach for
- Rounded corners on a flat-sided shape: hull() of cylinders at the corners. It is fast, exact, and easy to reason about.
- Every edge and corner rounded, in three dimensions: minkowski() with a sphere, on a shape that is a simple convex block.
- A smooth transition between two different shapes: hull() of one of each.
- Anything with a hole or a cavity: build the solid outside first, then subtract the empty parts last.
The whole file
Here is everything in one piece, ready to paste into OpenSCAD or download, with the three objects laid out side by side as in the picture above:
// OpenSCAD Part 6 -- smooth shapes with hull() and minkowski()
// hull(): the tightest convex skin around everything inside it.
// Four cylinders at the corners become a box with rounded corners.
module rounded_box(w, l, h, r = 5) {
assert(r > 0 && 2*r <= min(w, l),
str("r is ", r, "mm; it must be positive and no more than half of the shorter side (", min(w, l), "mm)"));
hull()
for (x = [r, w - r], y = [r, l - r])
translate([x, y, 0])
cylinder(r = r, h = h, $fn = 48);
}
// An open tray built from two rounded boxes: one minus a smaller one.
module tray(w = 100, l = 60, h = 25, r = 8, wall = 2.4, floor_t = 2.4) {
assert(r > wall,
str("r is ", r, "mm; it must exceed wall (", wall, "mm) so the inside corners stay rounded"));
assert(h > floor_t,
str("h is ", h, "mm; it must exceed floor_t (", floor_t, "mm) or there is no cavity"));
difference() {
rounded_box(w, l, h, r);
translate([wall, wall, floor_t])
rounded_box(w - 2*wall, l - 2*wall, h, r - wall);
}
}
// minkowski(): slide one shape all over the surface of another.
// A cube "swept" by a sphere is a block with every edge and corner rounded.
// The result grows by r on every side, so shrink the cube by 2*r
// and shift it by r to keep the overall size exactly w x l x h.
module soft_block(w, l, h, r = 3) {
assert(r > 0 && 2*r < min(w, l, h),
str("r is ", r, "mm; it must be positive and less than half of the smallest side (", min(w, l, h), "mm)"));
translate([r, r, r])
minkowski() {
cube([w - 2*r, l - 2*r, h - 2*r]);
sphere(r = r, $fn = 24);
}
}
// hull() with two different circles: a tapered link between two holes.
module link(spacing = 40, big_d = 20, small_d = 12, t = 5) {
hull() {
cylinder(d = big_d, h = t, $fn = 48);
translate([spacing, 0, 0])
cylinder(d = small_d, h = t, $fn = 48);
}
}
// ---- Scene: one of each, side by side ----
tray();
translate([130, 0, 0])
soft_block(40, 40, 25, r = 6);
translate([200, 20, 0])
link();
Two modules, one habit
Neither tool does anything you could not do by hand with more cylinders and a lot of patience. What they change is where the rounding lives. In the modules above it is a single number, r, and everything else follows from it, and the asserts say which values of r the shape can honestly accept. Round corners are a decision about the design, so they belong in one place where you can change your mind.