montage

From Atoms to Bits to Atoms: A Cat Toy’s Journey

I thought I would fol­low up the pre­vi­ous cat toy post with another one. I’m not obsessed with cat toys!  Really!  They just make good geo­met­ric mod­els.  The main con­tent of this post will soon go into an Instructables page as an entry to win a 3D printer in the Make It Real Challenge, but I wanted to start with a copy here on my own blog.

There are some cat toys at the house that are par­tic­u­larly pop­u­lar with the local res­i­dents.  They are sim­ple hol­low spheres with cut-out slots.  They are great for kit­ties to kick around — small and light.  After star­ing at one for a few min­utes, piec­ing out the geom­e­try, I real­ized that this would make a great instruc­tional design for an intro­duc­tion to 3D CAD mod­el­ing using sim­ple geo­met­ric shapes and boolean trans­forms.

Before we begin, you will need two things:

  • A copy of OpenSCAD. This is “free” in every sense of the word — it costs noth­ing AND is an Open Source project that peo­ple from around the globe con­tribute to and use.  You can get it for Mac, Windows, or Linux.
  • A web browser tab open to the OpenSCAD User Manual. OpenSCAD works like a pro­gram­ming lan­guage and although I’ll step you through the process, it is always good to have a lan­guage ref­er­ence handy.

If you look at the orig­i­nal cat toy, it is a ball.  That is to say, it is a hol­low sphere (or spher­i­cal shell if you want to get fancy).  That ball then has slots cut away at reg­u­lar inter­vals.  I did a lit­tle bit of mea­sur­ing before­hand.

Let’s start by mak­ing the sphere. This is a sim­ple one line “pro­gram.” There is an extra line up top that you can mod­ify to pro­duce dif­fer­ent detail lev­els. I find that a value of 30 is good to do most work in, though I bump that up to about 100 when I am ready to pro­duce a final ren­der. This sphere has a radius of 20mm. Remember that the radius (20mm) is half of the diam­e­ter (40mm).

DETAIL = 30;

sphere(r = 20, $fn = DETAIL);

Type this code into the text area on the left of the OpenSCAD win­dow. Go to the “Design” pull­down menu and select “Compile.” In a few moments, you should see a sphere in the right half of the OpenSCAD win­dow. You can click and drag with your mouse to rotate the 3D shape and use the mouse wheel to zoom in and out.

If we were to print this sphere on a 3D printer, it would be solid.  We don’t want a solid ball, but a hol­low shell.  Let’s sub­tract enough away to give us a 2mm shell.  We do this with the dif­fer­ence() func­tion.  This func­tion takes a list of two or more objects, draws the first one, and then sub­tracts each of the other ones.  In this case, we will make a slightly smaller sphere inside and sub­tract it.

DETAIL = 30;

difference()
{
    sphere(r = 20, $fn = DETAIL);
    sphere(r = 18, $fn = DETAIL);
}

Now, select “Compile” or use its hotkey (F5). Note that on my key­board (a Mac), the F5 key is actu­ally key­board bright­ness and I have to use the “Fn” key to use it as an F5.

In the graphic win­dow you will see.... some­thing that looks exactly like what you had before. Except it is hol­low now. How do you know? Let’s take a quick bite out of it with a cube.

DETAIL = 30;

difference()
{
    sphere(r = 20, $fn = DETAIL);
    sphere(r = 18, $fn = DETAIL);
    cube(size = [20, 20, 20]); // temporarily use this to peek at the thickness
}

This pro­gram starts with the big sphere, sub­tracts out the smaller one, then sub­tracts out a cube.  You may have to use your mouse to rotate around, but it should look some­thing like this:

Now remove that cube line.  We will do some­thing very much like that to cut out the slots, except instead of cubes, we will use cuboids, which are the rec­tan­gles of cubes.  Let’s just start with one to see how to line things up.  We’ll do this:

DETAIL = 30;

difference()
{
    sphere(r = 20, $fn = DETAIL);
    sphere(r = 18, $fn = DETAIL);
    cube(size=[80, 40, 5]);
}

You’ll end up with a sphere with a slit sim­i­lar to a Cylon eye strip.  What’s going on here?  Shouldn’t that have cut out a rec­tan­gle?  It did, but the rec­tan­gle was placed directly on the ori­gin.  If you select “View -> Thrown Together” from the pull­down menus, then “Design -> Compile” you’ll see the com­bi­na­tion of shapes.  This is an extremely use­ful view of your vir­tual world when you are try­ing to sub­tract shapes and don’t under­stand what is going on.

We want it to com­pletely inter­sect from one edge of the sphere to the other.  To do that, we’ll need to slide it over a bit.  We can do that with the trans­late() func­tion, which takes the object fol­low­ing it and shifts it around on the x, y, and z axis.  Let’s try it.

DETAIL = 30;

difference()
{
    sphere(r = 20, $fn = DETAIL);
    sphere(r = 18, $fn = DETAIL);
    translate(v = [-40, 0, 0])
        cube(size=[80, 40, 5]);
}

That’s the strip we’re look­ing for, but it needs to be off­set just a bit from the cen­ter to give us that cen­tral sup­port col­umn.  Let’s tweak that y value over a lit­tle bit more.

DETAIL = 30;

difference()
{
    sphere(r = 20, $fn = DETAIL);
    sphere(r = 18, $fn = DETAIL);
    translate(v = [-40, 4, 0])
        cube(size=[80, 40, 5]);
}

That’s great!  Now we just need to add a few more!  I’m going to adjust the height from 5mm to 4.45mm to get them to divide a lit­tle more evenly across the sphere.  Let’s add some more trans­lated cubes.  It takes a lit­tle bit of math to get the posi­tion­ing right, but you can add one at a time, exper­i­ment with posi­tion­ing, and play with the results as you go.

DETAIL = 30;

difference()
{
    sphere(r = 20, $fn = DETAIL);
    sphere(r = 18, $fn = DETAIL);
    translate(v = [-40, 4, -20 + 2 * 4.45])
        cube(size=[80, 40, 4.45]);
    translate(v = [-40, 4, -20 + 4 * 4.45])
        cube(size=[80, 40, 4.45]);
    translate(v = [-40, 4, -20 + 6 * 4.45])
        cube(size=[80, 40, 4.45]);
}

Finally, the other half of cutouts goes in, off­set from the first set.  The code looks almost exactly like the first half:

DETAIL = 30;

difference()
{
    sphere(r = 20, $fn = DETAIL);
    sphere(r = 18, $fn = DETAIL);
    // right side
    translate(v = [-40, 4, -20 + 2 * 4.45])
        cube(size=[80, 40, 4.45]);
    translate(v = [-40, 4, -20 + 4 * 4.45])
        cube(size=[80, 40, 4.45]);
    translate(v = [-40, 4, -20 + 6 * 4.45])
        cube(size=[80, 40, 4.45]);

    // left side
    translate(v = [-40, -44, -20 + 1 * 4.45])
        cube(size=[80, 40, 4.45]);
    translate(v = [-40, -44, -20 + 3 * 4.45])
        cube(size=[80, 40, 4.45]);
    translate(v = [-40, -44, -20 + 5 * 4.45])
        cube(size=[80, 40, 4.45]);
    translate(v = [-40, -44, -20 + 7 * 4.45])
        cube(size=[80, 40, 4.45]);
}

Finally, you can crank up that DETAIL value when every­thing looks good.  This will give you a higher qual­ity 3D model with more sur­faces, but it takes a lit­tle longer to gen­er­ate.  Go to “Design -> Compile and Render” on the pull­down menu for your final ren­der.  Assuming that looks good, go to “Design -> Export as STL” to save it as a 3D file.  Most 3D print­ers and 3D print­ing ser­vices use this file for­mat.

Congratulations!  You cre­ated a cat toy using geom­e­try!  Time to print!

On a home 3D printer, even if you build using sup­port struc­tures, the upper slats will have grav­ity work­ing against them.  They’ll end up sag­ging a bit and kind of stringy on the bot­tom.  You will get a ball that is struc­turally sound, but looks a lit­tle warped.  If you have a small metal file or X-Acto knife, you can man­u­ally clean it up a lit­tle.  Industrial print­ers typ­i­cally do not suf­fer from this sort of prob­lem because they use a dif­fer­ent process for print­ing and sup­port.

I have a zip file (cat_ball.zip) con­tain­ing source for each of these steps.  It also con­tains a mondo-mega final OpenSCAD file called a para­met­ric model.  This is a model where all of the impor­tant num­bers are dis­tilled and extracted to the top (much like DETAIL is in the above exam­ples).  This then lets you eas­ily change the size of the ball, the wall thick­ness, the num­ber of slots, and the width of the sup­port struc­ture (i.e. the depth of the cuts).  You can then make all sorts of crazy vari­ants just by chang­ing a few num­bers.  You want one that is 50mm in diam­e­ter with a 5mm thick shell and 19 cutouts?  There you go!  But good luck print­ing this vari­ant on a home 3D printer.

 

Posted in: MakerBot Projects

One thought on “From Atoms to Bits to Atoms: A Cat Toy’s Journey

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>