This article deals with the modeling and animation of gears, providing a short tutorial for the utilization of the Blender Mechanical Gears (BMG) script.

Introduction. One of the key points in modeling and animate mechanical devices relies in the need to produce gears. Gears are not merely “wheels with teeth”. Gears were like that in ancient days, but modern mechanics deeply studied the different ways in which spin can be transferred from one rotating axis to another, defining exactly how a gear must be designed for maximum efficiency.

Some theory can be obtained from the docs on [1] (I don’t want to promote any particular gear manufacturer, but this is the reference I used to create my gears) as well as in the Blender Mechanical Gears (BMG) script documentation [2]. Basically a gear must be designed so that no friction occurs at two meshing gear teeth. This ensures efficiency, long duration, and low noise. The mathematical description of a gear is based on the involute concept. The involute of a circle has several properties; the most important of which is that teeth of meshing gears whose profile is an involute do not slide one on the other while the gears rotate, and the pressure angle with which a gear pushes the other stay constant.

I will not go deeper on this here; you don’t need to know, since the BMG will handle mathematics, but if you are curious just browse [1,2].

The Script. BMG is a script suite you can download from [3]. It comprehends two scripts, a mesher (BMGm) and a spinner (BMGs) we will concentrate on the former first. BMGm belongs to the Mesh category if you elect to install it in the proper position within the .blender tree. In any case, once launched, it presents a screen as shown in Fig. 1

BMGm can create Cylindrical and Conical gears… the worm option is not working, yet ;). In this article we will concentrate on cylindrical to demonstrate script usage.

Figure 1. BMGm startup screen
Main Gear Parameters. This group of parameters defines the basic look of the gear. When two meshing gears are set what defines the geometry is the Pitch Radius, which is the radius of the ideal circle on which the meshing teeth of the two gears touch. It is the pitch radius the one defining most of the gear geometry. This, as most over entries, is defined in Blender Units. We will keep the default 5 for now. The teeth number defines how many teeth the gear has. This is the second most important parameter, and we will set this to 25 for this example. The Pressure angle is vital, from a mechanical point of view, but is of less importance in computer graphics. It defines the angle between the tangent plane to the gear tooth at the contact point and the plane containing the two gears rotation axis. It is probably better to leave this to the default 20° value. Helical Angle defines helical gears shape. Common gears have straight teeth. Helical gears have slanted teeth. Helical gear are less noisy and more swift in operation, and more costly to manufacture, all things you don’t care in 3D graphics, so we will keep this angle to 0 now. The Addendum and Dedendum defines how far beyond and beneath the pitch radius the teeth extends. These parameters are critical. First the Addendum cannot be greater than the dedendum, or you will have big meshing problems. Second, Their value must be tuned according to the number of teeth. The more the teeth, the smaller these two must be, the fewer the teeth, the larger they can be. For our example 25 is an average teeth number, so we can keep them to the default 0.4 value.
Beveling: No true mechanical devices have sharp edges. Fillet defines the radius of the rounding at the top and bottom of the tooth. Bevel defines the beveling of all edges on upper and lower face of the gear.
Mesh Parameters: The script generates a single tooth for the gear, with a given refinement level in the mesh. The refinement level is given as a Resolution along the tooth perimeter, which should be kept to 2 unless you are planning to zoom in a lot (rise it) or zoom out a lot (lower it) on your gears and a Longitudinal Resolution along the tooth thickness. This is actually needed only for helical gears, which do exhibit longitudinal twist. Finally the Thickness defines how thick is the gear and the Width defines how much to the inside, with respect to the pitch circle, the body of the gear extends beyond the tooth. Keep all these to their defaults
Pinion. There is no point in defining a gear without is matching pinion. The pinion can be either a standard pinion (a gear) a rack (a straight toothed item) a crown (a big gear with teeth on the inside) let’s keep the Pinion option and maintain the 12 teeth.

If now you press the Generate button you will see the scene in Fig. 2

Please note that the script generated a single tooth both for the main gear and the pinion. The main gear object center is in the origin, the pitch radius is 5 blender units, you can see this since the teeth would touch there, once rotated. The pinion radius has been automatically computed by the script, its center is in the right position for correct meshing (rightmost yellow dot) and the tooth has been produced slightly rotated for the sake of clarity.

Our next task will be to complete the gear and the pinion mesh.

Figure 2. BMGm result (top view)
Gear Meshes touch-ups. First of all, rotate the main gear tooth 1/50 of 360° (7.5°) (Fig. 3.1). This makes lower edge of the tooth aligned on the xz plane. In front view and edit mode we can extrude the top vertex to complete the profile (Fig. 3.2). Duplicating this and moving it around on the xz plane will make the profile for the inner gear part too (Fig. 3.3). Now duplicate all these new vertices and mirror them along global z with respect to cursor.

Figure 3. Profile completion
Now go back in top view with all these new vertices selected. Ideally we should spin (counterclockwise) three copies in a 14.4° angle. Sadly Blender does not accept decimals here! So we will spin them 15 copies along a 72° angle. (Fig. 4.1). Now Select the tooth, and SpinDup it by 5 times by 72°. You will have an extra copy of it (Fig. 4.2), which you should delete. Now remove doubles.

Figure 4. Some further steps…
Rotate the gear 36° clockwise, to have it symmetrically placed with respect to the xz plane. Now extrude some vertices from the inner part (Fig. 5.1 and 5.2) and extrude it towards the outer ring, merge some vertices where needed. It is also a good idea to use the Bevel script to make this arm nicer.

Figure 5. Almost finished!
Now you only have to SpinDup on 288° 4 copies and remove doubles! You might wish to scale the inner part a little along z only to make the gear less flat. Do something similar with the pinion too. But you won’t have the space to make the mesh so complex. Remember that the pinion has 12 teeth so a tooth is 30° (360°/12) wide. At the end you should have something like Fig. 6. Give to the Gear Object a mnemonic name (Like ‘Gear’) and to the pinion object a mnemonic name too (‘Pinion’ is a good choice!)

Figure 6. The two gears
Preparing for Spinning! To have the gears spin properly you will need to set up few things, but first, since two gears only is really a sad model, select both gears, duplicate them and move the copies so that the new Gear is coaxial and beneath the original pinion (Fig. 7). Give the duplicates smart names, like ‘GearB’ and ‘PinionB’. Be very careful, the Pinion and the GearB objects must have same x and y location, and an offset on z.

Figure 7. The four gears
Now add an empty for each gear, located in the gear center, with the z axis pointing in the direction of the gear rotational axis, then parent gears to empties. Give them matching names (Fig. 8).

Figure 8. The four gears parented to their proper empties
This is necessary because the spinning script (BMGs) will handle rotations for the gear as relative to the z axis. If the gears are to be moved and are not lying on the xy plane this will results in odd behavior.

By parenting gears to empties and by moving/rotating only the empties from now on – never the gears – the animation will behave properly.

Now launch the BMGs script. It is an ‘Animation’ class script. It will present quite an empty interface, with just an Add button. Press it four times and four lines will appear. In these line first column presents a Gear Object name. Fill ‘Gear’ in the first and ‘Pinion’ in the second, ‘GearB’ in the third, ‘PinionB’ in the fourth. Second column specifies the teeth number. ‘Gear’ and ‘GearB’ have 25, ‘Pinion’ and ‘PinionB’ have 12. This completes our gears database (Fig. 9.1). The gears database holds info on which objects in your scene is really a gear and should be spinned. You can Save and Load database to/from disk, the script generates XML files. You are advised to do so because the databases will be lost when you quit blender (The automatically generated script for spinning will not be lost!)

Now switch to the ‘Link’ Panel. Add three lines here with the Add button. The new lines appearing contain information on which gear is connected to which other. The first column in each line contains the driving gear, the second column the driven gear. The third column specify the link type, which can be a mesh kind of link, in which the pinion rotates in the opposite direction with respect to gear and the speed is given by the gear speed modified by the tooth number ratio. For coaxial gears, that is, for gears not meshing but rather mounted on the same axis the link type is fixed because the rotation speed is the same. In rare cases, with crowns and helical gears, the speed might still be in the tooth number ratio but not in the opposite direction. For these cases the InvMesh option exists.

In our example in the first line we will state that ‘Gear’ is the driver, ‘Pinion’ is the driven and the link is of ‘mesh’ type. On the second line ‘Pinion’ is now the driver, ‘GearB’ is the driven and the link type is ‘fixed’ since they are rigidly bound. At last, third line states that ‘GearB’ is the driver to ‘PinionB’ in a ‘mesh’ type link.

The Links database defines a consequential series of actions. If a driver gear is rotated its rotation propagates to its driven pinions and from these to their own driven gears and so on. To facilitate maintenance the two small buttons on the right allows changing links order.

Figure 9. Setting up gears and links databases
Once the links database is done (Fig 9.2) we are done. You should now press the Generate button. This creates a new script, named DriverSL (Fig. 10). This new script is stored in the .blend file and will not be lost when exiting Blender (You must have saved your file, of course).

Figure 10. Spinning script, automatically generated
To complete the set-up go to Script context in the Buttons Window and add a Scene Script link on FrameChanged event. Put DriverSL as linked script (Fig. 11)

Figure 11. Setting the Script Link
Let’s Go! Now we’re really there! First make a quick Frame 1 to Frame 2 and back switch. If some gears are not at 0 rotation they will revert to it (In this case our pinions) and you might have to rotate their empties (not the gears themselves!!) to recover a proper mutual meshing between gears.

Now select the driving gear, in our example ‘Gear’. And add to it a non-constant rotation IPO on RotZ (only on RotZ).

Now press ALT-A. The driver Gear will start to rotate, and the Pinion and all other gears will follow with a correct matching velocity!

Figure 12. Setting the IPO
• The three links at the bottom of the article all point to the same place and entering the third into

• @Jeffrey: I removed the bottom 2 links, they seem to be dead. But the first link worked for me. Lemme know if your still having problems.

• Chek

Thanks a lot for this tutorial. It’s a big help. I’m pointing a few more people to it.

• Great article, has a lot of useful information in it.

• manoj kumar

its excellent to us ethe blender for our engineering projects…