Getting current object in a python expression driver


In a driver on a property of a material, I want to know the name of the object on wich this material is applied.

The material beeing applied to different object, I want to have a different behaviour in my python function depending on the object.

Is there a function like ‘self’ to designate the object onto which is my driver.

More detail :

  • I created a material
  • Assigned this material to cube1 and Cube2
  • Added a driver on one property (transparency alpha) of this material
  • In this driver I call the function :

def invert(x):
v =[“Cube”][‘prop_vis’]
return v

Instead of “Cube” i’m looking for a function that would give me the name of the object on which the driver/material is assigned (prop_vis is a custom property defined on each object)

As someone any idea ?



You need a different material for each object. Think about it, even if you can detect the object from the driver interface, both objects will change to whatever value is returned once the driver is evaluated.