I have a driver on x rotation with this expression and "Use_self" ticked:
-var/.35 + self["prop"]

I have a custom property named "prop" with float
If I change the value with the UI it's working and make my mesh turn with the offset value
If I try to change the value with this script it changes the value in the property (if I'm hovering on the field otherwise it's not) but not in the 3dviewport
Looks like an update problem ?

C = bpy.context
obj = C.object
obj["prop"] = 2.08

1 Answer 1


Update driver


import bpy

obj = bpy.context.object

obj["prop"] = 2.08

fc = obj.driver_add("rotation_euler", 0)
dr = fc.driver

dr.use_self = True
dr.expression = 'radians(self["prop"])'

when change the custom property

import bpy

def find_fc(fcs, path, index = None):
        return fcs.find(path) if index is None else fcs.find(path, index = index)
        return None

obj = bpy.context.object
obj["prop"] += 1

# update the driver
fc = find_fc(obj.animation_data.drivers, "rotation_euler", index = 0)
if fc is not None:
    dr = fc.driver
    dr.expression = dr.expression

If use self in your driver expression, make sure enable Auto Run Python Scripts

enter image description here

  • $\begingroup$ Perfect, thanks a lot XY. Do you think it's possible to offset the driver value not using custom property but with just a global variable ? I use self["prop"] in my driver expression because I don't know how to pass a global variable from my script. $\endgroup$
    – cscholl
    Jul 16, 2022 at 9:18
  • $\begingroup$ Not sure. But when you close the file, the global variable disappears. The next time you open the blend file, it won't work. $\endgroup$
    – X Y
    Jul 16, 2022 at 9:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .