Learning CAD, Designing with openSCAD

F2!? seriously openSCAD F2!!!???what the hell?
It was an hour into my first experience with designing with openSCAD, when disaster struck. But I’m jumping ahead, lets go back to the beginning…

If you’ve looked around my blog you’ll know that I have a desire to make a CNC router. I have constructed what might pass for the 3-axis mechanism. However, I lack any of the electronics, motors etc required to make it go. There is not an insubstantial cost to getting from where I am now, to a working machine. In the last year I have not really been able to justify taking things further, but it does remain a firm plan. One day, I will have a cnc router.

Part of the difficulty justifying the cost, is that difficult question ‘so what are you actually going to do with it?’ to which ‘I’m gonna make!…erm, stuff!, and the computer will control it!’ is not quite good enough. So I need ideas that can be fulfilled with a cnc router. On top of that, I need to know how to take those ideas and get them to the point that the only thing missing is a cnc router.

Enter Computer Aided Design (CAD), cnc machines take instructions in the form of tool path vectors, this information needs to come from an accurate computer model of what you want, and that all starts with CAD. There is no point having a cnc anything if I’m still drawing on scraps of paper and totally out of scale.

And so my journey began, I need to learn to compose my ideas in CAD software, so that one day I can process those files to my cnc machine. And until that day I can use the designs even for hand construction, even if it is slower and less accurate. So job one, find some CAD software and try to mode something. In this case I’ve been kicking around an idea for a rotating wine rack, something that will fit in a small under-stairs cupboard and maximise use of the space. The base of this idea is an octagon platform with supports to hold bottles in layers that interlock slightly.

winerack render

So I want to draw an octagon in some CAD software….how hard can it be? I fired up Autocad, and set to it. cubes, right no problem, but how do I make an octagon? or a polygon generally? I found the interface very hard to use, working on the 3d space trying to figure out which clicks, where would activate various features. After some considerable messing around and getting no where, I decided to switch to Blender to see if I had better luck. But again I found myself frustrated by an inability to accurately control the interface. Perhaps with training and time I’d appreciate how fast and beautiful it is but for now I was getting no where fast and getting annoyed.

Then I hit upon openSCAD, this is a completely different approach, in openSCAD you write script to describe what you want, you get a bunch of standard primitives, a way to define polygons to extrude, and a set of translation, rotation, union and difference commands with which to maneuver and compose objects. Now, programming is what I do all day long for a job, so this felt like home to me, picking up the language was pretty easy and before you know it I had my octagon base and the first draft of a set of wine bottle supports

Then disaster…yes, openSCAD crashed. I think I may have accidentally told it to compile/render whilst it was already doing so, whatever happened it crashed. There was a chance to attach a debugger which I hoped might help, but it didn’t work and the app went down hard.

I fired it back up to discover that openSCAD has no auto-save feature, and furthermore hitting ctrl+s *doesn’t save* because some idiot made it F2…!”$”£%£”$.

I like most in my profession hit ctrl+s pretty much on autopilot every few seconds, anytime I pause to think, any time it feels like it’s been too long. lots of hard lessons about saving are ingrained in a compulsion to save constantly. But all of that was for nothing, as hitting ctrl+s wasn’t doing anything. And so I lost about an hours work and had to put the laptop down for a while before I could even consider starting again. This was not a good start to my experience with openSCAD.

However, it really is much easier for me to use than the more ‘traditional’ CAD software, I understand it much more, and having gotten the hang of it, it took relatively little time to get back to where I was and beyond.

winerack render_bottles

One thing I really like is that you can make anything into a module, then call that multiple times. you can include files as libraries, so it was easy for me to have 1 file in which I define the ‘parts’ of a design, then another in which I call them and move them into position to render what the finished item is supposed to be. Then finally a third file which calls the parts and just renders them into a form I can use as a template.




I can figure out how best to layout the pieces to us the least wood possible. When happy I just aligned the view to front, and printed out the image. It took a couple of guesses to get it to print at 1:1 scale, so that I could literally cut the pieces out and use them as templates. But this worked pretty well and made things easy in the garage when I marked everything up and cut things out.

Obviously this is also required for my cnc router, whilst it’s nice to have a file which renders what the finished item is going to be like, what the machine will need to know is what shapes to cut out of a flat piece of wood.

In all I consider this to have been a success, though you can judge for yourselves when I blog about the finished wine rack. I will certainly use openSCAD again for designing things, and getting everything to scale and figured out before I start cutting wood. I will learn to hit F2 on a regular basis, which is actually helped by having the multiple file setup, since you need to save the parts adjustments before you can re-render the views. And one day, I will have a cnc router to do the cutting.

, ,

2 responses to “Learning CAD, Designing with openSCAD”

  1. Here is a solution to your Ctrl-S habit.
    Use your favourite text editor for editing, instead of doing it inside openscad. Then in openscad, choose “View/hide editor” to avoid seeing the code in openscad, and “Design/Automatic reload and compile” so that when you switch from your code editor to openscad it’ll load and display your latest model.

    Then if openscad crashes, it won’t take your code with it. And you can set up your editor to syntax highlight the openscad code, if your editor lets you set up custom syntax highlighting.

    I don’t think I’ve had openscad crash, as such, but it does freeze the whole windows rendering system solid now and then. ctrl-alt-delete unfreezes it without closing anything, but it is sure annoying. I’m guessing it is a problem with a rendering library, but the devs are mac people, and aren’t likely to find or fix the problem in a hurry.

    • That is a top tip, thanks! I’ve had the issue with hanging the rendering engine too, and also discovered ctrl-alt-del gets me back. normally i then have to quit openSCAD and start again.