Slicing and Dicing with OpenSCAD

In my quest to make a cool coaster, I wanted a way I could slice up a model so that each face could be printed, well, “face-up”, so I don’t run into problems with overhangs and supports and stuff gumming the works.  I would then glue the model together later.   (In the case of Coasters, I can also swap filaments and have the design “pop” on each side)…

In the process, I learned some OpenSCAD:

  • F5 = “quick”, F6 = slow and build
  • No such thing as “export this object”, it just builds and then you can choose to export everything.
  • variables are lexically scoped, ie, more like constants.  There are some dynamic variables as well.
  • I had to remember some algebra.
  • I applied some D.R.Y.

Here’s the result as applied to http://www.thingiverse.com/thing:60728 – first in “ShowMe()” mode:

image

And then SliceEverything() mode without the full fledged CSG operations:

image

And then SliceEverything() in the way that I could export an STL:

Yeah, that crashed.   It was too complicated.  I hate to take out the // Slice Everything, and instead, here’s just the front and an ear, exported to STL, and viewed in NetFabb.

imageimageimageimage

Note: Its NOT fast, when doing the full build (F6).  It also crashes less if run from command line – apparently the crash is during rendering to the screen?)

Show Me The Code

Since its getting a bit long, I’m linking to github below; but this is what it looks like, approximately:

imageimageimage

link to code at github

update:  I’ve tried to use this approach for several things now, and … its very fragile.  So fragile, that I have successfully used it to create a print.  Almost every model is “too complex” and fails at render.  I might need to try a different language.. something that is rock solid.