Book of the Week: Python for 3D Printing

By on December 24th, 2019 in book

Tags: , , , , ,

 Python for 3D Printing: Using Python to enhance the power of OpenSCAD for 3D modeling [Source: Amazon]
Python for 3D Printing: Using Python to enhance the power of OpenSCAD for 3D modeling [Source: Amazon]

This week’s selection is “Python for 3D Printing: Using Python to enhance the power of OpenSCAD for 3D modeling” by John Clark Craig.

This book dramatically illustrates the potential achievable when you mix two different technologies: the sum is often more than the parts. In this case it’s the conjunction of a programming language (Python) and a 3D modeling system (OpenSCAD). 

What Is OpenSCAD?

While most 3D modeling systems might be recognized for their drag & drop or drawing input methods, OpenSCAD is nothing of the sort. Instead of using a visual method of creating 3D components, OpenSCAD uses a programmatic approach. 

Basically you type in a series of steps to gradually add 3D portions and modify shapes. Here’s some example statements: 

module example_intersection()

{	intersection() { 
		difference() {
			union() {
				cube([30, 30, 30], center = true);
				translate([0, 0, -25])
					cube([15, 15, 50], center = true);
			}
			union() {
				cube([50, 10, 10], center = true);
				cube([10, 50, 10], center = true); 
				cube([10, 10, 50], center = true);			}
 
		}
		translate([0, 0, 5])
			cylinder(h = 50, r1 = 20, r2 = 5, center = true);
	}}
 example_intersection();

It’s very much like programming: you must understand the sequence of execution and a whole lot of commands. However, there is a massive benefit to this approach: you can very easily tweak the design by simply editing one of the parameters. In the above example, we could change the size of one of the cubes by merely typing different dimensions. 

What Is Python? 

Python is a programming language that has more-or-less become the most popular environment for creating software these days. It’s very easy to learn, and yet quite powerful. There are countless extensions to make it even more powerful. 

As a programming environment, it is possible to read in text files and output texts files. 

Wait a second! Aren’t the OpenSCAD 3D models basically text files? 

They are. 

The idea is to use a powerful programming environment to modify or even generate OpenSCAD 3D models. There are many things that can be done. How many different programs can be created? Well, it’s a big number, a very big number. 

This book explores this fascinating space between programming and 3D modeling. It begins with a basic explanation of both Python and OpenSCAD, with instructions on where to obtain and load them. 

Most of the book is focused on exploring how to generate particular 3D models using this hybrid approach. They’re pretty straightforward, but the idea is to learn the ropes of using Python to generate or modify OpenSCAD 3D models, and then take that knowledge forward to perform even more complex 3D model generations. 

Via Amazon

By Kerry Stevenson

Kerry Stevenson, aka "General Fabb" has written over 8,000 stories on 3D printing at Fabbaloo since he launched the venture in 2007, with an intention to promote and grow the incredible technology of 3D printing across the world. So far, it seems to be working!