Octagony (or, Reinventing the Wheel)

Scaling-in-openscad
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 circle
circle(r=2.4);

And here's the result - an octagon!?

Typical-small-circle-openscad

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 circle
scale([.1,.1])
circle(r=24);

 

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

Awesome-scaled-circle-openscad

 

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. 

 

Filed under  //   Octagony   OpenSCAD   ThingThatCouldHaveBeenBroughtToMyAttentionYesterday  

About



Twitter:
@hugs
@bitbeam
@saucelabs