# Drivers: How to access “self”?

Quick question:

I'm trying to set up a driver which uses the Y-scale of whatever object the driver is on (which means that I don't want to use the Y-scale of a specific object, but rather any object).

I've read that the option "Use Self" is perfect this exact scenario, but I can't figure out how to use the self variable.

Someone suggested I use bpy.data.objects[self.id_data.user.name].scale.y in the python expression but that returns an ERROR: Invalid python expression.

What am I doing wrong? Thanks!

• I don't have the time to test it right now, but have you tried self.scale.y? – user27640 May 28 '17 at 14:20
• Hi Duane, thanks for the fast reply, but that too yields the "ERROR: Invalid Python Expression" message. – alterdings May 28 '17 at 14:32

Using self in a driver is not as straight forward as thought, though it is really easy once you know where to put it. In short: In your driver, simply don't declare a variable, but use self in the expression itself to reference to the object. Check this screenshot here:
This driver is hooked up to the scale.y property of an object. The important bit here is to check Use Self as indicated in the upper screenshot, so Blender actually declares what object self is pointing to automatically.
Now you can copy and paste this driver to any other object, it will take the scale.x from there as a driving source.
• @alterdings That's the reason why you're having trouble. self in this case is not what you might think! If you read the tooltip on the Use_Self checkbox, you'll see that self can be an object, but also a bone, etc. Trouble is, that your driver lives on a Shader Node Tree. I'm not sure if self in this case is the Node Tree or the Material, but I'm almost certain it's not the object. And it can never be, because Blender allows materials to be shared across multiple objects. If now you had, say two objects using the exact same material, BOTH would try to alter the mix node of THE SAME material. – aliasguru May 28 '17 at 18:44