Creating 3D Models for 3D Printing Using OpenSCAD by Leithauser David

Creating 3D Models for 3D Printing Using OpenSCAD by Leithauser David

Author:Leithauser, David [Leithauser, David]
Language: eng
Format: epub
Publisher: Leithauser Research
Published: 2020-10-31T16:00:00+00:00


Figure 12.1

​ You can see that this makes it much easier to distinguish the individual pieces, including where each piece ends. You can, for example, easily see that the lower cube is actually part way inside the taller cube. If your intent had been to put that cube on the edge of the taller cube, you can see your mistake. Note that if you do not include the color command, the piece defaults to the yellow.

​ I want to emphasize that this does not affect your 3D model or exported STL file at all. In fact, when you press the F6 key for the actual rendering, the colors will disappear. The purpose of this color function was originally for other uses for OpenSCAD, like creating pictures, but you can use this as a diagnostic tool in developing your models.

Temporarily remove pieces from your model

​ Sometimes when you have created a complex model, it is hard to get a look at individual pieces. You can remove individual pieces from the model temporarily by several methods.

​ One way is to put a double slash (//) at the beginning of the line describing the piece. For example, in the following code, the cube will not be shown.

sphere(5);

//cube(8);

cylinder(h = 10, r = 2);

Listing 12.2

However, this can be a rather unreliable. Suppose you have put a line break in the description of the piece, such as in the following code

sphere(5);

translate([20, 0, 0])

cube(8);

cylinder(h = 10, r = 2);

Listing 12.3

If you put the double slash in the beginning of the translate line, only the translation is removed and the cube is still shown, but not translated. If you put a double slash in the beginning of the cube line, the translate command will be applied to the cylinder.

A better way in most cases is to put an asterisk in the beginning of the line. This tells OpenSCAD to ignore the object. In the case of Listing 12.3, putting an asterisk in the beginning of either the translate line or the cube line causes the cube to disappear without affecting any of the other pieces.

There is a situation where you might want to use the remark option to temporarily remove objects. That is where you want to remove a large number of objects. There is another type of remark marker. If you put a slash followed by an asterisk (/*) in the code and later in the code put an asterisk followed by a slash (*/), everything in between will be treated as a remark and not used. For example, in the code in Listing 12.4, all the cubes disappear.

sphere(5);

/*

translate([20, 0, 0]) cube(8);

translate([20, 20, 0]) cube(8);

translate([0, 20, 0]) cube(8);

*/

cylinder(h = 10,r = 2);

Listing 12.4

Making a component transparent

​ Instead of removing a component completely, you can make a component transparent and tinted red by putting a pound sign (#) at the beginning of the line describing it. For example, the code in Listing 12.10 gives you the picture in Figure 12.3 when you press F5.

#translate([0, 0, 10]) sphere(10, $fn



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.