# Round corners for Openscad - Tutorial

## by WilliamAAdams, published Jun 15, 2011

Round corners for Openscad - Tutorial Jun 15, 2011
0 Share

### Thing Apps Enabled

Order This Printed View All Apps

## Give a Shout Out

If you print this Thing and display it in public proudly give attribution by printing and displaying this tag.

Print Thing Tag

# Summary

I've been thinking on OpenScad libraries and tutorials of late, and in the process discovering more of what OpenScad can and can not do. Sometimes there are gems that I had not seen before, and I have a 'smack my forehead' aha moment.

This thing is a little bit of a tutorial on how to do rounded corners on things using the 'hull()' builtin module.

I derived from this other thing because although there is already a 'boxes.scad' that comes with the standard OpenScad, it shows that there's more than one way to skin a box.

The 'hull()' method basically fills out a convex hull based on the points that are layed out in 2D. In the case of a rectangle, you can essentially just place circles at the corners, and use the hull() with a linear_extrude(), and you've got your rounded rectangle thing.

{
x = size[0];
y = size[1];
z = size[2];

``````linear_extrude(height=z)
hull()
{
// place 4 circles in the corners, with the given radius

}``````

}

It's as simple as that!

What I like about this is the flexibility. You're not limited to rectangles. You can layout as many little circles as you like, with any radius, and the hull() method will 'do the needful'.

Another way to do this is to use a hidden gem calls minkowski sum:

{
\$fn=50;

``````minkowski()
{
cube(size=[x,y,size[2]]);
// Using a sphere is possible, but will kill performance
}``````

}

If you use \$fn=12, then you can use the sphere, and get rounded corners all around. Higher values will be more round, but will really take a long time to render.

Personally, I'm not totally clear on the limitations of using minkowski. Apparently, if you tried to the it this way:

{
linear_extrude(height=height, convexity=3)
hull()
for(pt = polypoints)
{
translate([pt[0], pt[1], 0])
}
}

You'd get an error related to minkowski.

At any rate, there are multiple ways to do things with OpenScad. Even though there are many libraries available, it might prove useful to explore the possibilities anyway as you might find another way that better suits your needs and situation.

# Instructions

2) Play with it
3) Explore OpenScad to discover new gems
4) Rejoice!

# All Apps

3D Print your file with 3D Hubs, the world’s largest online marketplace for 3D printing services.

Auto-magically prepare your 3D models for 3D printing. A cloud based 3D models Preparing and Healing solution for 3D Printing, MakePrintable provides features for model repairing, wall thickness...

Kiri:Moto is an integrated cloud-based slicer and tool-path generator for 3D Printing, CAM / CNC and Laser cutting. *** 3D printing mode provides model slicing and GCode output using built-in...

KiriMoto Thing App

With 3D Slash, you can edit 3d models like a stonecutter. A unique interface: as fun as a building game! The perfect tool for non-designers and children to create in 3D.

Print through a distributed network of 3D printing enthusiasts from across the US, at a fraction of the cost of the competitors. We want to change the world for the better through technology, an...

Quickly Scale, Mirror or Cut your 3D Models

3D Print a wide range of designs with Treatstock. Easy to use tools to get the perfect result. The global 3D printing network that connects you with high-quality and fast working print services nea...

nice, I added this together with this thing https://www.thingiverse.com/thing:1264391, epic : )

The Ultimate box maker

The radius should not be divided by 2, otherwise it's not accurate

rbuckland - in reply to ThePiGuy

yes, the corrected module is

``````module rounded_cube(size, radius)
{
\$fn=50;
minkowski()
{
cube(size=[x,y,size[2]], center=true);
}
}``````

Nice, and thanks for the idea. However, I am going to start in 3d, with cylinders rather than circles, saving the linear_extrude. Perhaps it is a new feature in openscad, but hull() works wonderfully in 3d, not only to create cubes with 4 round sides, but also blending from cylinders to cubes. Just what I need for the cooling fan duct I'm designing for my 3D printer.

Yah, considering I did this tutorial more than 3 years ago, I'm sure OpenScad has improved. Perhaps you could make a 'derivative' of this thing, and show the new way of doing it. That way, anyone who lands here can benefit from seeing the new hotness.

Jan 22, 2015 - Modified Jan 23, 2015

the cooling fan duct is complete and in the end I didn't need the 3d rounded cube module. The first part of the design was the mounting flange for the fan. For that I needed the centers of the 4 holes, and just used them for the 3d rounded cube (4 cylinders hulled together.
For the part of the duct that surrounds the extruder, I used a 2d rounded rectangle and a rotate_extrude.
The 2 ended up, more or less, joined together by with a cylinger and a rounded rectangle (with a small linear_extrude) hulled together. Everything is doubled for the outside and inside surfaces.
I'll sort out the derivate at the weekend.

How do I make a something like full_round_rect?

I like this version better, it matches cube() better:

x = size[0];
y = size[1];
z = size[2];

``````linear_extrude(height=z)
hull() {

transla``````

}
}

Cool tutorial, thanks!

However, for your Minkowski example, I think you multiply the corner radius by 2, not divide, ie:

2;

...if you want the x and y size you specify to correctly specify the outer dimensions of the final object.

Yah, I saw that after I posted.

Really, it's just

One way you can do this in rapcad is using 3D convex hulls:

module rounded_cube(w,h,d,dia){
hull(){
sphere(d=dia);
translate([0,h,d])sphere(d=dia);
translate([w,0,d])sphere(d=dia);
translate([w,h,0])sphere(d=dia);
translate([w,h,d])sphere(d=dia);
translate([0,0,d])sphere(d=dia);
translate([w,0,0])sphere(d=dia);
translate([0,h,0])sphere(d=dia);
}
}

rounded_cube(10,10,10,5);

Nice approach - pity about the iterated version. Hope they enhance / fix that in future.

Hull hull ? :-) never did see that one in the documentation thanks!

Btw, minkowski support for 2d objects and the hull function are both fairly recent additions to [email protected], so if these do not work for you, upgrade to a newer version.

Lenbok - in reply to Lenbok

Damn phone autocomplete, openscad not [email protected]