what is scripted expression syntax

So i want to use drivers with option “scripted expression”? for example typing “frame” in var field gives me my propertie equal current frame. If i want for example cube1 locX be equal cube2 rotZ? what is syntaxis. I tryed wiki’s :

math.pi * 2 + 5.0

Blender.Get(“curframe”) # the current animation frame

math.sin(Blender.Get(“curframe”)) # the sine of the current frame

self.LocX * 10

but non of this dos not work for me with 2.6
Please help!

to set cube1 locx to the rotation of cube2 rotZ
enter for
the driver of cube1-locx (insert a single-driver … switch to fcurves->drivers)
a variable (±sign)
and select as object: cube2
and as part the transform: rotation-Z-axis
(check you have the right rotation-mode … XYZ-Euler … and not quaternions…)

then enter into the expression field:
var

press return, maybe enable debug to view the current values …
… you know the rotations are in radians …?

for conversion to degrees, just use
var*360/pi

frame was only a recent and handy addition. For

math.sin(Blender.Get(“curframe”)) # the sine of the current frame

you can type

#sin(frame)

straight into the property as shown here.

Using driver variables in expressions

custom functions for driver expressions.

explanation of transform space

run down of the driver system (some features have changed)

test-dr… whoops mate… 2pi radians = 360 degrees… anyway why not use the maths functions

radians(deg)

or

degrees(rad)

lol, yep! batFINGER, you are totally righty right.
I have some braindamage from my setting for the cyclic wobbling
of some very important body-parts - and those body-parts
dont wobble/jiggle in the full cycle of one walk-animation/run-animation,
they have only half of the cycle of the base-animation.

thank’s a lot. Amazing functionality!!!

I understand how to set up scripted expressions using the gui, but how exactly do you set a Scripted Expression using python?

Edit:

Ah, I figured it out. For anyone else wondering, this is how you set a driver’s expression with python, assuming you are setting the very first driver element in the driver list:

bpy.data.objects['rig'].animation_data.drivers[0].driver.expression = 'expression goes here'