From the course: Creating a Captive Sphere with OpenSCAD

Adding a sphere

- Let's now add a sphere to our cube. We'll type a return to make a new line, and you can see how OpenSCAD automatically numbers the lines. We'll type the word sphere to make a sphere, and we now have to define its size, just as we did for the cube. Now with the cube, the 30, the size, indicates the length of a side. With a sphere, the number you type indicates the radius of the sphere. So let's open a (, and let's make this 20 millimeters in radius. And we close the ) again. Once again, we have to type a ; to tell OpenSCAD it's the end of a line. And let's preview that. And there is our sphere, inside that cube. Now, it seems to me that when this is subtracted from the cube, this piece here is going to be too thin to print effectively. So let's make this sphere a little bit smaller. Rather than 20, let's take this down to a radius of 19 millimeters. And that's better. This gives us a thicker structure that'll make it easier to print. Now, you'll notice that the sphere comes out automatically centered on these axes, because that's the way that spheres are drawn in OpenSCAD. Unlike the cube, we don't have to specifically tell the program to center it. It's centered by default.

Contents