The traditional way to create models for 3D printing is to design them using a CAD program. Typically, the designer will draw a few rough shapes to build the basic outline of the part, extrude them, then add other features and/or remove material for holes, bezels, cutouts, etc. This works well for many designs, and is deservedly by far the most popular way of creating 3D models. However, it’s not the only available method. Creating models in code, from mathematical operations, opens up design possibilities that would be difficult or impossible to reproduce manually.

If you want a hole in your model, for instance, it’s generally straightforward enough to draw a circle and extrude it into the material. But if you want four hundred of them in a 40×10 matrix, that could take a while. And smooth, mathematical designs like a Moebius strip can be nearly impossible to create by hand.

A Moebius strip and the code to produce it in OpenSCAD. (Click for larger.)

OpenSCAD is a Free, Turing-complete modeling language for the creation of 3D models based on mathematical primitives. Basic shapes such as cubes, spheres, and cylinders can be scaled, translated, rotated as well as added to, subtracted from, and intersected with other objects. Control structures such as for loops allow for the automatic assembly of more complex objects like corkscrews based on the mathematical formulas. Define the shapes, and OpenSCAD creates the model.

Printing your creations is straightforward. After finishing the code for your design, press F6 to render your design (using a more accurate method than the quick preview). Once rendered, the design can be saved as an .stl file to be sliced into g-code by the slicer of your choice.


This entry was posted in 3D Printing, Coding, Math, Tools and tagged , , , , , . Bookmark the permalink.

Leave a Reply