Octagony (or, Reinventing the Wheel)


In the “Things That Could’ve Been Brought To My Attention Yesterday” Department, I just found a huge time saver in OpenSCAD — the scale function.

By default, OpenSCAD’s built-in circle and cylinder functions are fine. However, for small circles or cylinders with a radius of less than 3mm, the result doesn’t look much like a circle at all. This is how a newbie would code this in OpenSCAD.

// Typical small circlecircle(r=2.4);

And here’s the result – an octagon!?


The solution is to create a circle with a large radius, then scale it down to the size I want. My trick is to use a radius 10 times larger than I need, then use the scale function to reduce it to 10% of its original size.

// High-precision small circlescale([.1,.1])circle(r=24);


And the new, better, non-octagon-y result:



Why does this matter? Bitbeam requires a Lego Technic compatible through-hole radius of 2.4 mm. If I used the default octagon-producing output, and sent it to the laser cutter, round axles, dowels, or bolts would not have fit in the hole. My first remedy was to draw a circle in Inkscape, export to DXF, then use OpenSCAD’s linear_extrude function to import my circle and render. DXF-to-OpenSCAD is usually awesome and is featured prominently on the OpenSCAD home page. However, I’ve thankfully realized it’s total overkill for my simple small-radius circle. Trying to figure out how to create a circle in Inkscape in an OpenSCAD-compatible way was surprisingly complicated and tedius. Credit goes, though, to Nudel for posting an excellent and detailed Inkscape to OpenSCAD dxf tutorial. I will definely use that tutorial in the future for more sophisicated designs.

The goal for all of this is “Click, Click, Awesome.” I believe we’ll get there. 


This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

4 Responses to Octagony (or, Reinventing the Wheel)

  1. Anonymous says:

    Actually, a better solution to your problem is to use the $fn variable. Try this:circle(r=2.4, $fn=30);

  2. Anonymous says:

    Tony, cool! Thanks for that trick. I’ll update the post. Although, it feels like the default is wrong. It should look "circle-y" at small sizes out-of-the-box.For others reading these comments: here are the relavant doc links:http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_the_2D_Subsystem#circlewhere it says "The special variables $fn, $fs and $fa can also be used to improve the output."and then this link, too.http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features

  3. Anonymous says:

    I’m not sure why OpenSCAD makes small circles with less fragments. I always thought it was because when you’re doing 3D printing, it’s often best to make small circles with fewer sides since you don’t feed it real curves. A ton of tiny movements in a small circle often ends up with too much plastic filling the hole.

  4. digitaljestin says:

    I’m a bit late to this thread, but I made a video a few months back on the topic of special variables: http://www.youtube.com/watch?v=-0BLRkcqeW0

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s