instead of "self" provide the name of the "self" object so that you can use it in driver functions
Self is "nice", but not sufficient. Everyone who ever wrote more than 3 driver functions himself - not just expressions - needs to access the object with the driver on. You cannot achieve this (AFAIK) with self. With the name given you could easily access it by yourself with bpy.data.objects[name] and access any modifier/data/custom property you need. Without it - you are really restricted to some very very basic functions. And no - no driver use wants to add that name to each (same) driver he uses for probably over 100 objects.
2 Comments
If I had to make over a hundred drivers, I would use Python instead of the GUI x)
That being said, the issue here isn't that
selfdoesn't access the owner, it's that:The properties which
selfcan access are limited for performances and security reasonsIt's clunky (You'd think that the prompt asking you if you want to enable python execution to make it work, would actually make it work. But no, for some expressions to work, you will still need to manually enable Autorun Python Script , and it won't tell you which ones require it);
The python paths are not the same as bpy's and there's, e.g. for an object's x location:
location[0]location.xWhat
selfpoints to isn't always obvious depending on where the driver is set:selfis the Cube object ✅selfis the pose bone ✅selfis the metallic property⁉️I don't think there's any documentation or GUI hints for any of that.
I've found this BSE post that explains how you can print the available properties of a given owner in the console.
My version of that would be to use the expression:
Which gives something like this:
And use
0 if print(self.name) else 1to print the name of the owner.But considering that simple expressions with
selfare slower to execute than using variables, that it requires lowering your security, and the trial and error it is to even setup something functional withself, and that you should automate driver creation via scripting anyway if you need bigger scale, then you might as well never useselfoutside quick testing when you already know how access specific properties with it.I’ve never heard of “driver functions” as opposed to a scripted expressions . Would you provide a documentation link to explain?