Atoms from Bits: Programming OpenSCAD for Laser Cutting

nodebots-day-ann-arbor International Nodebots Day 2015 is July 25. I’m helping with an event in Ann Arbor and we needed over 40 robot kits for people to play with. What better time to learn how to use a new CAD package?

OpenSCAD is a great introduction to CAD for programmers that’s fun to use and easy to learn. It’s definitely not a replacement for a commercial CAD system such as Inventor or SOLIDWORKS, but I was able to create fully parametric wheel designs much quicker and easier than if I tried to use a 2D drawing program.

OpenSCAD

If you’ve ever seen CAD software before, OpenSCAD is a little shocking. The programming area is larger than the graphics display!

simple-wheel_scad

Chris Farber wrote about OpenSCAD in 2013. The software has seen many improvements since then, but has kept true to the idea of a simple, programmable solid modeling system.

You can see in the screen shot above that OpenSCAD creates things by running a program. It’s actually impossible to draw anything by clicking in the graphics display. I defined one main module to create the wheel geometry and a helper module to create the servo motor mounting holes for attaching a wheel to a motor.

OpenSCAD uses a custom language, but the syntax and features will feel familiar to most programmers. Constructive solid geometry will be a brand new idea to many programmers, but it has so many similarities to set operations that it too will probably be quickly learned.

Generating SVG

OpenSCAD_Model OpenSCAD definitely works best when creating solid models for 3D printing, but simple models can be laser cut if you can live with two limitations: you must design flat parts, and you must allow for the cutting tool in your dimensions. OpenSCAD does not have any concept of a cutting tool’s kerf. Most laser cutters can generate a decent tool path from a simple vector drawing, but none cut narrow enough kerfs. You will definitely have to plan for your specific laser when cutting accurate parts.

The laser I used cut a kerf about 0.5mm at best focus. The only critical tolerance is the mating holes to the servo motors, and I just tweaked the geometry through trial and error. The final wheels are about 1mm narrower in all dimensions. They will still make fun nodebots.

Once you have finished the design in OpenSCAD, press the “Render” button to project the geometry onto the XY plane, then export an SVG. There aren’t any options to control the SVG, so you’ll probably have to do some data cleanup. Even though my wheels are fully parametric and I could generate all the variations in one run, I rendered and exported each wheel separately to give me the flexibility in cleaning up the SVG.

All of the CAD files and SVG exports that I cut can be found in my github nodebots repo.

Laser Cutting

The SVG can’t be printed directly because my laser only cuts hairline (0 width) vectors. You can see in the SVG above that OpenSCAD exported vectors with 0.5pt and filled polygons. This needs to be cleaned up in a vector editing program. I used Corel Draw, but Inkscape and other vector editors work fine.

One oddity of OpenSCAD is that it creates unitless geometry. I treated all dimensions as mm, but when importing the SVG into Corel, the sizes were wrong. I just selected the piece and manually set the dimensions of the wheel. If your vector editor doesn’t support setting accurate physical dimensions, you’ll have a very hard time getting accurate cuts.

My final wheels were cut from 5mm Launan plywood. It is inexpensive, light, and strong. The front and back are clear wood, but I painted it anyway to seal the charred edges–laser cut wood will smudge forever regardless of how well you try to remove the char. The wheels were cut on an Epilog 50W laser cutter at Maker Works, a fantastic maker space in Ann Arbor. Launan cuts well on the laser at 10% speed and 100% power. 24 inch by 12 inch sheets of 40 wheels took 35 minutes to cut.

 

Conversation
  • When you say “I just selected the piece and manually set the dimensions of the wheel.”, what do you mean by that?

    Does that mean you worked with the dimensions in your SCAD file until they exported to the size you wanted? Or does that mean you take the imported SVG and use Corel to scale it to size?

    I’m going to MakerWorks tomorrow afternoon, trying out a simple SCAD design using this workflow. Any tips (for a complete beginner with laser cutting) will be appreciated :)

    • Ken Fox Ken Fox says:

      I used Corel to scale the wheel after it was imported from SVG.

      SCAD exports the entire projection together and Corel imports the projection as a single object. I was disappointed that I couldn’t define the units for the SVG dimensions when I imported it into Corel–I have no idea what units Corel expects the SVG to use. Maybe pixels?

  • Thanks for the info, Ken.

    One more question, if you don’t mind: The SVG export creates a path with a background color of grey. Does that have to be made transparent before sending to the laser? Or is it just ignored?

    Thanks again, for helping a n00b :)
    Brian

  • Also, it seems like it would be useful to figure out the pt:cm ratio between SCAD and this process. How do you accurately create a design with drill-holes for mounting points if you need to scale the entire thing? Preferrably, I can create a design in cm within SCAD using a multiplier (or some other mechanism) so that I can put my drill holes exactly 2 cm apart, for example.

    Just thinking about this process a bit. I really like the SCAD -> Laser idea. But the unit conversion/scaling has me noodling.

    • Ken Fox Ken Fox says:

      The scaling is a clunky UI step in Corel, but it doesn’t affect your SCAD design or the precision of the laser cuts. You just treat all dimensions in SCAD as mm or whatever you want, and then force the object to be the right size in Corel. The SVG comes in as a single object, so forcing the outer dimension of the object will scale everything in your design.

      If you have two separate SCAD parts and you import them into Corel, you’ll have to use Corel to make the final assembly. Corel is fine at doing precise print layout, so it’s fine at doing precise laser cutting too.

      Aligning the center of holes is super easy. The only tricky problems you will have are those where you need a cut hole or cut part to be a precise dimension. The laser cuts are about 0.5mm wide. If you cut a square exactly 10mm x 10mm in SCAD, it will come out 9.5mm x 9.5mm. If you cut a hole exactly exactly 10mm in diameter, it will come out 10.5mm.

      Machining software can figure out the cutting paths so that cut parts match your designs. The combo of SCAD, Corel and the Epilog printer driver aren’t that smart though.

  • Ken Fox Ken Fox says:

    The lasers I’ve used pretend to be a printer, but how they convert print commands to laser power depends on the driver.

    The Epilog driver interprets zero width lines (called hairline in Corel) as vector cuts. The power, speed and frequency of the cut are configurable as print options. The Epilog driver can also map colors to laser power, but most people I know just use black lines which will be the default configured power.

    Maker Works training class covers what all the options mean and there’s a big poster on the wall for what settings work best for different materials. Epilog’s driver has some online docs at https://www.epiloglaser.com/products/legend-laser/legend-print-driver.htm

  • Alan Bernstein says:

    I’m currently learning to use a laser cutter, and OpenSCAD was already my favorite CAD program for 3D printing, so I’m in the process of adapting it for my laser (ULS). I’ve found that I can streamline the OpenSCAD-Corel process by making two simple changes to the SVG file:

    Add unit to the dimensions in the svg tag (default is unitless)
    <svg width="50mm" height="50mm"
    Change the stroke-width in the path tag (default is 0.5):

    By experimentation, I found that any width < 0.385mm will work.

    I also wrote a simple script to automate these steps, though I'm sure it has some bugs I have yet to find.

  • Comments are closed.