As part of the Advanced Computational Methods 2 module, Ashley Setter and Thorsten Wittemeier gave an introduction to Constructive Solid Geometry (CSG) with OpenSCAD. A complete blog post accompanying this session is provided here.
Ash started by giving a general introduction to CSG. Constructive solid geometry is an approach to modelling solid objects where simple objects are combined using Boolean operators. As opposed to CAD software, a scripting language is used. You can then use the operations: Union, difference, intersection and geometric transformations (translation and rotation) to build more complex objects/shapes.
He then went on with an introduction to OpenSCAD, a free software tool for creating solid 3D CAD models. The CAD models are produced using a script which is coded in a language similar to C and is compiled to render a 3D model from this script file. This means that the models are easily reproduced, distributed, and altered.
After this introduction to the topic, Thorsten gave an overview about the syntax of the underlying functional programming language. One of the most apparent differences to imperative programming languages like C is the fact that variables are assigned at compile time, not at run time. In this sense they are somewhat similar to constants in other languages. New OpenSCAD users have to get used to the idea that expressions like x = x + 1 are not allowed. They will also have to understand that, even if a variable can be assigned at various positions of the code, every variable call will use only the last assigned value.
Operators in OpenSCAD are similar to C/C++, although increments and decrements are not supported due to the non-iterative nature of OpenSCAD. Mathematical operators can easily be applied to vectors and matrices. There is also a cross product function cross as well as a broad range of mathematical functions which mostly operate on scalars.
Ash continued with a live demonstration of how to construct simple geometric objects like cubes, spheres, and cylinders. He then went on with ways of refining these objects, followed by an introduction to transformations and the primary boolean operations union, difference and intersection.
A common problem experienced when using OpenSCAD to design an object for simulation or fabrication is zero thickness surfaces, literally surfaces defined in the design which have a thinkness of zero and so are completely unphysical. This typically happens when using the difference operation to make a hole in an object.
Finally Thorsten showed some practical applications for more complex geometries and gave an overview of some of the most important and useful external libraries.
To round off the presentation, exercise sheets were given to the participants, so they could actively discover the range of possibilities that OpenSCAD has to offer. Participants were asked to bring their own laptop with VirtualBox installed. A virtual machine image with OpenSCAD installed can be downloaded using the following link: