• Models
  • Contests
  • Slicer
  • Login
  • Start Here
    thingiverse-iconprintables-iconcults3d-iconmakerworld-iconmyminifactory-icon

    3D GO

    3D ModelsContestsCollectionsSaved ModelsOn a mobile device?

3D GO

Privacy Policy
Round corners for Openscad - Tutorial 3D Printer File Image 1
Round corners for Openscad - Tutorial 3D Printer File Image 2
Round corners for Openscad - Tutorial 3D Printer File Image 3
Round corners for Openscad - Tutorial 3D Printer File Image 4
Round corners for Openscad - Tutorial 3D Printer File Thumbnail 1
Round corners for Openscad - Tutorial 3D Printer File Thumbnail 2
Round corners for Openscad - Tutorial 3D Printer File Thumbnail 3
Round corners for Openscad - Tutorial 3D Printer File Thumbnail 4

Round corners for Openscad - Tutorial

WilliamAAdams avatarWilliamAAdams

June 15, 2011

thingiverse-icon
DescriptionCommentsTags

Description

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.

module roundedRect(size, radius)
{
x = size[0];
y = size[1];
z = size[2];

linear_extrude(height=z)
hull()
{
    // place 4 circles in the corners, with the given radius
    translate([(-x/2)+(radius/2), (-y/2)+(radius/2), 0])
    circle(r=radius);

    translate([(x/2)-(radius/2), (-y/2)+(radius/2), 0])
    circle(r=radius);

    translate([(-x/2)+(radius/2), (y/2)-(radius/2), 0])
    circle(r=radius);

    translate([(x/2)-(radius/2), (y/2)-(radius/2), 0])
    circle(r=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:

module miniround(size, radius)
{
$fn=50;
x = size[0]-radius/2;
y = size[1]-radius/2;

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

}

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:

module roundedPolygon(polypoints, paths, height, radius)
{
linear_extrude(height=height, convexity=3)
hull()
for(pt = polypoints)
{
translate([pt[0], pt[1], 0])
circle(r=radius);
}
}

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.

License:

Creative Commons - Attribution - Share Alike

Related Models

Bag Holder - Shopping Handle preview image

Bag Holder - Shopping Handle

ivanseidel profile image

ivanseidel

12,923

RC Boat CozyRC Mini Mono preview image

RC Boat CozyRC Mini Mono

NoMatter profile image

NoMatter

198

Galaxy Smart Tag 2 Hülle preview image

Galaxy Smart Tag 2 Hülle

MG1991 profile image

MG1991

26

3Dponics - Open-Source Collaboration - Building the Ultimate Space Farm preview image

3Dponics - Open-Source Collaboration - Building the Ultimate Space Farm

3dprintler profile image

3dprintler

7,300

Fix broken SD Card (3d-print plastic hull) preview image

Fix broken SD Card (3d-print plastic hull)

Sebastian profile image

Sebastian

57

Hundemarken Hülle Tasso case  preview image

Hundemarken Hülle Tasso case

Svenin3D profile image

Svenin3D

8

Hulk 3D Scan preview image

Hulk 3D Scan

3DWP profile image

3DWP

5,617

Shotgun Shell Crimp Remover (parametric 12ga, 20ga, 28ga) preview image

Shotgun Shell Crimp Remover (parametric 12ga, 20ga, 28ga)

Vik profile image

Vik

83