"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects." (Robert A. Heinlein)

Saturday 23 February 2013

Open SCAD: the programmer-oriented CAD

I often surf the Web looking for applications programming environments completely different from what I usually work with (I develop web application and services). Among these “completely different” things 3D graphics is one of the most appealing. So, while surfing the web I stumbled into this rather unusual CAD application: Open SCAD.

Open SCAD

Open SCAD is a 3D CAD application widely used among the 3D printers community. What makes it different from traditional CAD applications is the way you make your drawing: instead of using the mouse to drag lines, boxes in the classic four panels view (front, side, top and perspective) you “simply” write a program that defines how your drawing is.

Open SCAD language provides methods for the basic primitive solids like cube(), sphere(), cylinder() … methods to manipulate them like translate() and rotate(), CSG (constructive solid geometry) operations like union() difference(), intersection() … up to more complex operations like extrude() or rotate_extrude().


Lets draw something

I decided to try Open SCAD by designing something real: drawing the very simple TV stand I have at home and I assembled few years ago. Nothing fancy, indeed, just a plain wooden box, open in the front side, with a plane in the middle and a couple of holes in the back for cables. At first I started with a “copy-and-paste” approach by defining many cubes of the right size and translating them in place obtaining a code like this:


but then I stopped and decided to completely rewrite my code: I was getting the desired result but the code was going to be really ugly and I wasn't using most of advantages Open SCAD language offers. Open SCAD languages provide methods (called modules) and parameters in order to make code flexible and re-usable so I defined a module tvstand() which takes width, height, depth and panels thickness as parameters. Using module parameters all drawing parts can so be conveniently sized and placed.
Here is the code


you might not believe me but it has been easier, and faster, writing the parametric code than the hard-coded one. By the way here is the result.


Is it intuitive?

Open SCAD made me think about what an “intuitive” user interface means. We are used linking the idea of intuitive interface with an heavy use of graphics and mouse but this isn't ever true. Standard CAD programs, both 2D and 3D, try to reproduce the traditional, paper and pencil, process. I rarely feel comfortable with traditional CAD programs may be because I don't make a proper technical drawing since I was in high school. On the other hand, since I am a programmer , I immediately felt Open SCAD interface very comfortable since it's similar to the most IDE I used, it even use the usual “F5” key to compile.

2 comments :

  1. I heard alot about Open SCAD but first time I am reading any post about it. Nice review. What is the programming language which is shown in the left side of Open SCAD window?

    ReplyDelete
    Replies
    1. Thanks for visiting,
      the programming language you see it the one OpenSCAD uses to define 3D solids.

      Delete