This is not a pipe - From Bits to Atoms - The Maker's Manual: A Practical Guide to the New Industrial Revolution 1st Edition (2015)

The Maker's Manual: A Practical Guide to the New Industrial Revolution 1st Edition (2015)

Part III. From Bits to Atoms

Chapter 11. This is not a pipe

The bits-to-atoms revolution is bringing machines able to create real objects into our homes. These machines take minutes or hours to print a three-dimensional model, turning a file on a computer into something physical we can touch with our hands. The techniques used to create objects are many: we can deposit material, dig chunks out of blocks, create molds to be filled or forms on which materials are laid. We can create these objects by ourselves or with a community, and we can share them, download them from the Internet, modify them, and create them in our homes. It’s all about turning bits into atoms.

Manufacturing Processes

The technologies we are going to show you belong to two big families which, already existed long before the birth of the maker movement; they are just more accessible now.

When we were children and started playing with blocks, we learned that we could create objects by stacking or tacking together various pieces, layer after layer. In fabrication, this type of process is called additive manufacturing, because we add material on other material until we get the complete object. Some kinds of 3D printers work in this way. An extruder, sort of like a high tech glue gun, melts a plastic material and deposits it, layer by layer, where the computer model tells it to, until an object is created.

A sculptor uses a chisel and other tools to carve marble or wood, removing excess material and leaving behind a beautiful statue. In the maker world, computer numerical control (CNC) machines use a rotating tip similar to a dentist’s drill to grind away at blocks of wood, foam, resin, and even metals, leaving behind a sculpted object. This type of process is called subtractive manufacturing, because it subtracts material from a solid block of material.

Die cutting machines also remove pre-existing material, but they only work in two dimensions. They cut sheets of material using sharp blades, laser, or high-pressure fluid. Also, with these machines it is possible to create 3D objects by combining different parts, more or less like we do with wooden kits to build a dinosaur’s skeletons.

We can also combine the two techniques: for example, with milling machines and printers it is easy to create molds into which melted material is then poured slowly, or to create outlines to cover with papier mâché or fiberglass.

Starting from Bits

So you’ve got a design for a product. You’ve doodled it on napkins, and you’ve sketched it beautifully into a notebook. Now you need to turn that design into bits by converting your idea to a digital model.

To do this, you’ll use something called Computer Aided Design (CAD) software. Such programs let you sketch your design directly into a computer, in three dimensions. While many CAD programs store their files in a proprietary format, there are some standards such as STL, Standard Tesselation Language. In this format the objects are approximated with a series of triangles called a mesh; the more triangles, the better the model definition.

Software

One commercial software package appreciated by designers is Rhinoceros, also known as Rhino (Figure 11-1). It is easy to learn, can manage dozens of file formats,and can also be used for parametric design--the practice of letting algorithms influence design. With the Grasshopper plug-in, it can also create generative art.

Alt Text

Figure 11-1. A particularly light rhino

Blender, shown in Figure 11-2, is open source design software that is also able to carry out many operations beyond 3D modelling, like fluid simulation. Even though it was not specifically intended to create technical drawings, it is very good for the creation of files in the STL format.

Alt Text

Figure 11-2. Blender is a quite complex software, but it is very powerful.

The 123D Design software (Figure 11-3), available online, belongs to the 123D suite by Autodesk. It has been created by Autodesk to design printable objects in a simple way.

Alt Text

Figure 11-3. Autodesk 123D

Another package which is free of charge and quite simple to use is SketchUp Make (also available, for a fee, is the SketchUp Pro version). It doesn’t create files in STL format directly, so some plug-ins are necessary to convert the files, which makes the whole operation a bit more complex. It’s shown in Figure 11-4.

Alt Text

Figure 11-4. Trimble SketchUp Make.

A slightly different software package is 3DTin (Figure 11-5), which runs directly in browsers such as Chrome or Firefox. It is free to use, but the models created must be shared with a Creative Commons license. It can directly export files in STL format.

Alt Text

Figure 11-5. 3DTin is an online CAD application.

TinkerCAD (Figure 11-6) is an online editor, too. The basic version is free of charge for personal use, but not for commercial purposes. It has a clean and simple interface and it works more or less like 3DTin.

Alt Text

Figure 11-6. TinkerCAD.

OpenSCAD

In all the software we just listed, most of the input is done via the mouse. This can be a bit confusing at first, because you need some time to get the hang of how to operate in three dimensions on a flat two dimensional mouse pad. With Blender, which is wonderful, extremely powerful software, just to move an object runs the risk of getting lost in the middle of buttons, options, and menus of extremely complicated interface. For our purposes, we have decided to start with OpenSCAD, a free software package that may look a bit spartan (Figure 11-7) at first, but is powerful and easy to use.

Alt Text

Figure 11-7. OpenSCAD opening screen

There is no complex combinations of buttons, mouse movements, or interfaces to learn, but it has a quite different approach: it uses a very simple language to write scripts, that is, sequences of instructions. OpenSCAD compiles the scripts and shows you a 3D-image of the resulting object.

The interface only has three panels:

§ an editor in which the instructions for the design are inserted;

§ an area to visualize the object in 3D;

§ a console for system messages, errors and advice.

With OpenSCAD the mouse works only on the 3D viewer window and only lets you do three things:

§ move the mouse keeping the left button pressed to rotate the visualized object;

§ move the mouse keeping the right button pressed to shift the scene ;

§ use the mouse central wheel to zoom in or out.

Simple, isn’t it?

Before starting, in the rightmost window you can see three perpendicular straight lines, the three x, y, and z axes, meeting in a point called the origin. You can define the position in each point of the space keeping these axes as a reference: the x coordinate measures the distance of the point from the plane formed by the straight y and z lines, called yz; the y coordinate measures the distance of the point from the xz plane; the z coordinate measures the distance of the point from the xy plane. The origin coordinates are (0, 0, 0).

Hello, world!

Now, create a cube by writing the following instruction in the left box:

cube([1]);

Press F6 to make the software carry out your first script, and there you are; a cube 1 mm long on each side! The image is a bit small, so use the mouse wheel to zoom in if needed. (See Figure 11-8).

Alt Text

Figure 11-8. A simple cube.

Now you could also export your model in STL format to then create it with a 3D printer. To do this, choose the Design menu and click on Export as STL. Name the file and save it.

With the View menu it is possible to choose the point of view for our object, or choose between perspective and orthographic view.

Let’s do some more experiments with the cube control: if you use three different values, you’ll get a parallelepiped:

cube([2,3,4]);

The three numbers in the square brackets represent the length of the three sides of the parallelepiped.

OpenSCAD draws figures by always starting with a vertex on the axes’ origin. You can add a parameter and center the figure exactly in the origin:

cube(size = 5, center = true);

Beyond Cubes

Let’s try some other figures. To make a sphere, use the following instruction:

sphere(10);

The number in parentheses is the sphere radius. Different than the cube, whose origin is one of the vertexes, the sphere is centered at the origin. Figure 11-9 shows the rendered sphere.

Alt Text

Figure 11-9. A multifaceted sphere.

This sphere looks a bit too ... squarish. If you were to print this object, you probably wouldn’t be very happy with the result. It’s a good thing you can modify the resolution by adding the $fn parameter:

sphere(10, $fn=100);

Now the resolution is definitely better (Figure 11-10), although we haven’t reached perfection yet.

Alt Text

Figure 11-10. The sphere with a higher resolution.

Continue making experiments and set the resolution at 3 or at 1000 or any other number. In all of the examples below, and whenever you use OpenSCAD for our designs, you can choose the most suitable solution for your goals. After the sphere, here is a cylinder (Figure 11-11):

cylinder(h = 10, r1 = 10, r2 = 10, center = false);

The first parameter is the height, the second parameter is the radius of the top of the cylinder, and the third is the base of the cylinder. (This arrangement is pretty ingenious, in that it removes the need for a “cone” command; change the value of either the second or third parameter to zero and see what you get.)

Alt Text

Figure 11-11. The cylinder function can create cones and truncated cones

If you want a pure cylinder, instead of using two radius parameters, r1 and r2, you can use only one, allowing the other radius to default to the first. For the cylinder too, as well as for the sphere, you have the $fn parameter to determine the resolution.

Variables

In OpenSCAD you can use variables to store information you are interested in, like numbers or words, which you can use later. Each of these variables has a name, in order to distinguish it from the others. For example, you can name a variable “side”, and use it to represent, say, the side of a cube. You can assign a numeric value to “side” like this:

side = 7;

In this way you could create a cube with the following instruction:

cube(size = side);

You can use this variable for any shape:

circle(size);

Or even:

cylinder(size, size);

Why not just use the number 7 for all these shapes instead of a variable? Because if you want to change the size of all the objects at once, you only need to change the value of “size”.

Move slightly!

To create a second cube, you have to change some parameters. For example, type these three instructions into OpenSCAD:

side = 5;

cube(size = side);

cube(size = side);

Press F6 and see what happens. It looks like it hasn’t worked, because you can only see one cube. Actually there are two, but they are identical and they are exactly in the same place (the physical problem of two identical objects occupying the same intrinsic space at the same time doesn’t apply here). What can you do?

You can create an object in any location of the design space by using the translate function, specifying how far from the origin you want to move it along the three axes. Replace the last line of the code with the following two lines:

translate([10,0,0])

cube(5, center = true);

In this example, we have centered the cube on the origin and then moved it by 10 mm, as shown in Figure 11-12. You must not put a semicolon after the translate instruction, because the semicolon would terminate the instruction, and you need the translate instruction to apply to the next object.

Alt Text

Figure 11-12. A cube with a 5 mm side shifted along the x axis and centred

Now we’ve got it! But it’s not over yet…

Should you want to create a row of identical cubes, all at the same distance from one another, you could simply write an instruction for each cube, specifying how far you want to move it from the origin (you don’t have to move the first cube):

cube(size = 1, center = true);

translate([0, 0, 2])

cube(size = 1, center = true);

translate([0, 0, 4])

cube(size = 1, center = true);

translate([0, 0, 6])

cube(size = 1, center = true);

translate([0, 0, 8])

cube(size = 1, center = true);

translate([0, 0, 10])

cube(size = 1, center = true);

You have achieved the goal, but the situation risks getting out of hand very quickly.

Lazy is Good!

We are fortunate that OpenSCAD doesn’t only provide us with simple instructions, but also with a real programming language that is perfect for such repetitive commands. We want to draw a cube with a 1 mm side, then move upwards by 2 mm and draw an identical cube, again and again, until we get to 10 mm from the origin.

Let’s translate our intention in the OpenSCAD language. To repeat one or more operations for an arbitrary number of times we will use a structure called a loop.

The set of rules to create a loop is simple:

for ( z = [0 : 2 : 10] )

{

translate([0, 0, z])

cube(size = 1, center = true);

}

Essentially, you are saying to OpenSCAD: “Do what is included in the curly brackets. Start with z equal to 0, then repeat, increasing the value of z by 2 until you reach 10”. You could also say that, with the first line you create a sequence of even numbers from 0 to 10 and that at each iteration you repeat the block in curly brackets, replacing the z variable with its current value. Figure 11-13 shows the result.

The result is the same, but the script is much more compact and, after some experience, even more simple to read: in the prior example you place some cubes in pre-defined positions, but in this version, you can immediately understand that the origins of each cube are placed at the distance of 2 mm from one another. In the first listing the information is hidden, in the second it is evident.

Alt Text

Figure 11-13. Six cubes in a row.

You can also specify a precise irregular range of values:

for (z = [-2, 2, 6])

{

translate([0, 0, z])

cube(size = 1, center = false);

}

What’s the difference between this and the previous listing? The earlier listing, which had colons separating the entries in the for loop, iterates over a range of values. In that case, we told the software to count from 0 (the first value) to 10 (the last value), incrementing by 2 (the middle value). The software then figures out the values (0,2,4,6,8,10) it should use.

When you separate the values in a for loop with commas, we tell the software to use those exact values, and only those values. In the second example, we tell the software to use the values -2, 2, and 6--and no others.

You can also use the translate function to move more than one object, grouping the necessary instructions in braces:

translate ([5,0,0]) {

cube (1);

translate ([0,3,0])

sphere (1);

}

Note how, after having moved along the x axis in the first instruction, before generating the sphere, we move again along the y axis: you are nestingthe two translation movements one inside the other (Figure 11-14).

Alt Text

Figure 11-14. Shifting both a cube and a sphere.

Other Transformations

The scale function resizes an object along the three axes:

cube(10);

translate([15,0,0])

scale([0.5,1,2])

cube(10);

In that example, we have drawn a cube with a side of 10 mm, then we have taken a similar cube and we have moved it on the x axis by 15 mm, after applying the scale[0.5, 1, 2] function to it. The result is to halve the size of the cube side along the x axis, leave the dimensions unaltered along the y axis, and double the dimensions along the z axis (Figure 11-15).

Alt Text

Figure 11-15. Modifying the objects’ look with the scale function.

Sure, this function doesn’t seem very useful on a cube, but you can use it on a sphere to obtain a rugby ball or a flying disk.

To rotate the objects, you use the rotate function. To see how it works, draw a cone with the basis centered in the origin, then make a second cone identical to the first one and apply to it a 180 degree rotation around the y axis, so that it turns upside down (Figure 11-16):

cylinder(10,7,0);

translate([10,0,10])

rotate(a=[0,180,0])

cylinder(10,7,0);

Alt Text

Figure 11-16. Objects and rotations.

The optional ‘v’ parameter specifies an arbitrary axis to rotate around:

cylinder(10,7,0);

translate([10,0,10])

rotate(a=60, v=[1,1,0])

cylinder(10,7,0);

Practically, we define the axis around which we want our shape to rotate with a vector whose components along the three axes are [1, 1, 0]; to make it more simple, we can say that the direction of the axis is the direction of the segment that links the origin with the point of the (1,1,0) coordinates. The ‘a’ parameter indicates by how many degrees you want your object to rotate around this axis (Figure 11-17).

Alt Text

Figure 11-17. Rotation around an arbitrary axis.

The union command unifies two or more objects, combining them into one; here’s an example from OpenSCAD’s online manual:

union() {

cylinder (h = 4, r=1, center = true, $fn=100);

rotate ([90,0,0])

cylinder (h = 4, r=0.9, center = true, $fn=100);

}

Let’s look at what it does. It creates a cylinder, then creates another, slightly smaller cylinder at a 90 degree angle to the first one. Both cylinders are centered at the origin. The result is shown in Figure 11-18.

Alt Text

Figure 11-18. Union of two cylinders.

Just as it is possible to unify objects, you can also create a difference, which subtracts one object from the other. Let’s replace ‘union’ in the previous example with ‘difference’:

difference() {

cylinder (h = 4, r=1, center = true, $fn=100);

rotate ([90,0,0])

cylinder (h = 4, r=0.9, center = true, $fn=100);

}

See the result? Much as in the union example, the difference command creates a cylinder, then creates another, slightly smaller cylinder at a 90 degree angle to the first one. Only this time, instead of combining the two, difference subtracts the second object from the first.

OpenSCAD offers functions for 2-dimensional plane figures, too. The square command draws squares and rectangles; just like the cube function, it accepts the center=true parameter:

square ([2,2], center = true);

To draw a circle we can use circle. For circle you can again indicate the resolution with the $fn parameter:

circle(2, $fn=50);

There is no command to draw ellipses, but it is always possible to deform a circle. Here is a completely flat ellipse, with a 40 mm long main axis and a 20 mm long secondary axis (Figure 11-19):

scale([2,1,0])

circle(20);

Alt Text

Figure 11-19. The ellipse is obtained by deforming a circle.

You can also draw polygons by indicating a series of points and the paths linking them:

polygon(points=[[0,0],[100,0],[0,100],[10,10],
[80,10],[10,80]],

paths=[[0,1,2],[3,4,5]]);

The two-dimensional figures can be easily extruded into 3D objections with the linear_extrude command. Let’s try to extrude the polygon of the previous example by 100 mm, shown in Figure 11-20. If you don’t extrude your 2D objects, they won’t be printable.

linear_extrude(height = 100)

polygon( points= [

[ 0, 0], [100, 0], [ 0,100],

[10,10], [80,10], [10, 80] ],

paths=[ [0,1,2], [3,4,5] ]

);

Alt Text

Figure 11-20. Extruding a polygon

The linear_extrude command accepts other parameters too; for example, the center option, used to center the object while it is being extruded:

linear_extrude(height = 20, center = true)

circle(r = 10);

OpenSCAD also has a rotate_extrude() function that rotates the object around the z axis, allowing you, for example, to create toroidal (donut-shaped) objects (Figure 11-21):

rotate_extrude()

translate([20,0,0])

circle(r = 10);

Alt Text

Figure 11-21. A toroid.

For further details on the extrusion functions see the online manual.

Expanding OpenSCAD

Unfortunately there is not a native method to create text. But, luckily, you can expand OpenSCAD by using some libraries, which are software packages providing additional behaviors not included in the original version of the software.

On Thingiverse there is a library created by Phil Greenland that allows you to turn text into three-dimensional objects. Download the TextGenerator.scad file. To make a library available for all your projects you have to copy it in a specific folder, depending on the operating system you are using; usually the directories are:

§ Programs\OpenSCAD\libraries for Windows;

§ $HOME/.local/share/OpenSCAD/libraries for Linux;

§ $HOME/Documents/OpenSCAD/libraries for OS X.

Alternatively, to use it on a specific project only, you can copy it in the folder where you saved your OpenSCAD project file.

To use the library in a script, you have to load it with the use command. You can then write the text you want the drawtext command (Figure 11-22):

use <TextGenerator.scad>

drawtext("Hello World");

Alt Text

Figure 11-22. Hello, World