How to Export a 2D illustration of a 3D model in OpenSCAD

I've been getting into OpenSCAD lately—I'd rather wrestle with a text-based 3D modeling application for more dimensional models than fight with lockups of Fusion 360!

One thing I wanted to do recently was model a sheet-metal object that would be cut from a flat piece of sheet metal, then folded into its final form using a brake. Before 3D printing the final design, or cutting metal, I wanted to 'dry fit' my design to make sure my measurements were correct.

The idea was to print a to-scale line drawing of the part on my laser printer, cut it out, fold it, and check to make sure everything lined up correctly.

Some online utilities took an STL file and turned it into a PNG, but they weren't great and most wouldn't output a PNG with the exact dimensions as the model (they printed too big or too small).

Here was my model:

3D Model for Mounting Plate in OpenSCAD

If I tried exporting a PDF or SVG of the model (File > Export > Export as PDF...), it understandably didn't know what to do:

Error in OpenSCAD - object is not a 2D object

To get something exportable, I just added projection() at the top of my model to turn the top-down view into a 2D projection, then Rendered the object. Now it shows up as a 2D plane drawing:

2D projection of 3D object in OpenSCAD

And now the 'Export as PDF...' option (as well as the other 2D options like SVG) works great, allowing me to save a to-scale PDF suitable for reference or printing:

2D PDF output of OpenSCAD 3D model projection

I decided to put up this blog post in the hopes it might help someone else doing the same thing. My DDG searches weren't quite coming up with anything besides a few old GitHub issues.

Now I'm thinking of how much easier many of my Illustrator drawings would be if I just programmed them in OpenSCAD...

Comments

I'd love to read more OpenScad stuff in this blog. I teach crude programming to 17-year-old electricianstudents, and OpenScad is becoming an important part of my teaching. Especially how to spend less time waiting for rendering. Will my future cm4 or cm3 pi cluster be able to distribute the workload evenly?

At this time, it doesn't seem like parallel processing (or distributed rendering) is a priority for OpenSCAD, so you'd still have to wait for the single-threaded rendering to complete :(

I'm designing a box in Openscad to hold my electronics for my 3d printer, and I want a way to print out a slice of my design on my hp Laserjet to scale so I could set the board on it and see if the holes lined up before I start wasting pla 3d printing it. This was exactly what I needed. Thank you so much. FYI I recognize the name I just so happen to watch you video's and enjoy your channel keep up the great work..... One day soon I hope to see a GPU on a RPi lol

hey jeff.

wanting a parametric design tool, i also tried to get into OpenSCAD but ultimately decided that i didn't have time or brain-space for yet-another programming language. so stuck it out with Fusion 360 and have to say that there's value in once you get over the initial learning curve. i've found that adjusting the dimensions in the underlying sketches that support the models serves the functionality that i sought in OpenSCAD. switching to direct design is useful for quick tweaks (though the geek in me eventually wants to get around to turning those back into parametric design elements!) and of course comes with a lot of other neat functionality... for example bending of materials which i've found useful for a metal project of mine and may have been useful in your case too.

of course, it does also come with compute hardware requirements so i understand why it may not work for some.

look forward to your updates and youtube posts.

cheers,
me

That blog entry was very helpful - thanks !

Greetings from Germany
Juergen

Thx for this small guide but I stumbled over a constraint/bug/feature:
"projection()" doesn't work if your design is already 2D (only squares & circles etc. in the same height(0) instead of cubes & cylinders and what not).
But exporting such a design without "projection()" doesn't work either.

Solution: Had to give my 2D design artificial depth before "projection()" worked... (?!)

This is brilliant!
I had just gone to the trouble of installing a custom module to do laser printing.
It required using the command line to create a DXF file, which is not great for a laser cutter.
Wrapping the projection around my shape gave me a single export command with a high quality SVG result.
I can now cut my pattern easily.

Thanks so much.