banner perso

Some links about me. Many of my 3D designs are free. I also post on Google+ and in another blog,

Thursday, September 11, 2014

How to use Openscad (2): variables and modules for parametric designs

Part 2/5: Variable and parametric design

The previous part addressed the basics of Openscad. It relied mostly on "immediate values": we were providing dimensions as explicit numbers. If you want to tweak the design dimensions, then you need to parse the scad source code and fix the numbers all everywhere.

In fact "hard coded" numbers must be avoided. As opposed to "static" designs, parametric designs give the flexibility to tune the numbers very efficiently at one place only. The good point is that Openscad is one of the best tool to do so.

A larger mug by using the scale operator (from the "basic" tutorial).
This is still not parametric, as numbers are hard-coded (a bad practice).
See how the numbers in our mug design above depends on each other? If the cube is to be made taller for any reason, then the intersecting sphere and hollow cylinder must be tuned accordingly in the source code. And this is exactly something a computer can do better than us.

So let us first convert this design to a parametric version, i.e. a design that can be tweaked with a small set of parameters that all have a clear role (width, height and so).

How to use Openscad (1), tricks and tips to design a parametric 3D object

Part 1/5: Introduction to constructive solid geometry with Openscad

Some technical and non-technical people keep asking me how I create new designs. As often, after a few personal replies, I end up heading to the blog to share the answer as they keep asking for more.

Also I long wanted to write a pragmatic and step-by-step introduction to Openscad. The idea is to help people even with no programming skills (mostly in this part) and to bring newcomers to a point that they can design their own 3D objects (part two). Interestingly, Openscad is a really interesting tool to use to get a glimpse at what programming is because you get an immediate, visual feedback of your actions. Once understood, it may be much easier to move to other languages.

If only a few readers become "designers" by reading this I will be quite happy. Meanwhile I will have given a detailed answer to my friends and contacts!

A non-obvious GoPro mount of mine, that is fully customizable thanks to Openscad.
It looks complex, but it is still exclusively made of spheres, cylinders and cubes with a few basic "joints".
A forthcoming last part will deal with the complex features of Openscad. This one is for people that either learn fast or for those that are already proficient with the usual features of Openscad.
  1. Introduction to constructive solid geometry with OpenSCAD
  2. Variables and modules for parametric designs
  3. Iteration, extrusion and useful parametrized CSG techniques
  4. Children, factorized placement and chained hulls

So first, what is Openscad? Within the CAD family, it is a 3D modeler: a software that helps you to create 3D objects. There are many such tools, but this one is used extensively in the 3D printing community, not only because it is free but because is it really efficient for some kind of objects.

It may or may not suit your mind, but with time I am able to "see" the shape I describe, not as text but directly as shapes. I guess it depends on people, but I am sure there are people that are not programmers that can think alike. And if you are already a programmer with no industrial goal then you really should give it a try. It will be a breeze to use up to a productive level, especially if you do not want to invest time in a new and hellish interactive user interface!

The official manual is OK but it does not really work as an introduction. The navigation is also sometimes difficult to the point goggle is more useful. There is a nice raw cheat sheet also but it has no link to the respective functions (what a pity!) (update: it does now!). In any case these fail to help learning Openscad quickly in my humble opinion.

About Me

My photo

If you know me and you cannot tell exactly what my real job is, then you probably found the right Jeremie. Check for some pointers.

I am self-employed and I help start-ups, research centers, small companies with their needs related to computers, sensors, data processing and mechatronics. If you have a project and know what "R&D" is, then you already sparked my interest ;)