# What is the expected format fo scripted drivers?

After adding drivers to rotate the wheels when a car model is moved the wheels at one side of the car rotate clockwise (CW) but the wheels on the opposite side rotate counter-clockwise (CCW).

I want to animate the car and the wheels should move independently from the direction of movement. I first tried to use the distance to an empty like this, but it this leads to the CW/CCW problem. Changing the sign of the rotation would probably fix this, but it seems that there isn't an option for changing the sign of the driver value.

A scripted expression tested in the console window:

>>> print(bpy.data.objects['Mazda'].location.y)
-0.30693674087524414


Doesn't work in the script input field:

What format does Blender expect here?

It expects to not use direct data path but to use a variable like this:

The reason is for update purposes. With variable the driver knows what his dependencies are thus it knows what value to watch. Watching the whole bpy.data for changes is not efficient.

Here are examples what is allowed in the Expr. field. You can use number expressions with driver variables plus some build-in functions like sin, cos, min, max, frame, etc.(to see all of them put bpy.app.driver_namespace[' into console and hit Ctrl+Space)

You can also use custom python functions, where you can access bpy.data, but you need to add such functions to driver namespace first:

import bpy

def mazda_loc_y_func():
return bpy.data.objects['Mazda'].location.y


In the Expr. field you just type mazdaY(). Without the driver variable the driver might not update nicely though.