# How to rig a rotary counter?

I would like to know if is possible to create a simple python script to rotate these dials. What I want is something like this:

The first ring from the left is rotated around the Y axis by 40 degrees and when it reaches 40 degrees, the second ring is also rotated by 40 degrees and so on.

It could possibly be done with a Copy Rotation constraint but what i'd also like is to create a sudden shift of the dial every 40 degrees or so.

# Drive rotation of Empty2 by the rotation of Empty1

• In Properties panel (N to toggle):
• Right click on Y-Rotation axis of Empty2 and select Add Single Driver.
• In the Drivers section of the Graph Editor:
• Add a variable yrot, set Object to Empty1 and type to "Y-Rotation".
• Set driver scripted expression to: pi * ((180.0 * yrot / pi) // 40 * 10) / 180.0

This will give you an increase of 10° on Y-Axis of Empty2 for every 40° on Y-Axis of Empty1

Looking at your image you'd do this for the Y-Axis of your empties.

If you need increments of 10 on different rotation speeds, change the 40 in the above formula to i.e. 50

You can chain empties setup like this by making the next empty always driven by the previous. So the variable you add should be chosen from the correct object. The formula stays the same.

The main driving power behind this step-wise driving is the // floor division operator, which does integer division.

• it works like magic
– Utas
Jun 28 '13 at 22:11
• When I tried this it did not increment correctly. I am currently troubleshooting it and wondering: why is the number 40 given in your example? If there are ten digits (0~9) in a circular formation, and a 360 degree circle divided by ten is 36, should that be 36 instead? If you could explain a little more about how you got that formula it would be helpful. Sep 15 '14 at 12:06
• Update: I got it working. In my case I changed the code to be: pi * ((180.0 * xrotone / pi) // 360 * 36) / 180.0 ...but I still don't know why. Anyway my blend ticks one numerical increment every frame, at 30fps. The tick rate and frame rate may come into play here. Also the orientation of the numbers on the wheel - do they increase rotating in from the top or bottom, etc. Because I think the rotation needs a positive value to work. Sep 15 '14 at 12:18