Hi,<br><br>I've come across a bit of a problem with the 'self' keyword in pydrivers, which is used to refer to the Blender object that the driver belongs to.<br><br>I have a situation where I have several characters, with individual objects and armatures, but linked meshes. These characters are in groups, linked into scene files using the group/proxy features.
<br>i.e.  <br>ShapeKey1 -> Mesh1 -> Ob1 -> Arma1<br>ShapeKey1 -> Mesh1 -> Ob2 -> Arma2<br>(not entirely accurate but you get the idea)<br><br>I have a shape key on that mesh that I'd like to control with a bone in the armature, and I thought i should be able to do it with pydrivers. I wrote the following huge pyDriver expression connected to my shape key (eg. ShapeKey1), to find the armature (Arma1 or Arma2) which is modifying the individual mesh objects, and using a bone to control the shape key:
<br><br>self.modifiers[0][Blender.Modifier.Settings.OBJECT].getPose().bones['HeadShrink'].size[1]<br><br>This works, when I scale the bone, the shapekey changes, but the problem is it only works on one mesh object at a time. If I go to one of the other armatures, its respective mesh/shape key doesn't change. If I then select the second mesh object Ob2 and go to the shapekey pyDriver panel, and click the little 'gear' icon twice to disable and re-enable the pydriver, it will work fine, but then when I go back to the original character, it won't work.
<br><br>I had a look at the code and saw this at BPY_pydriver_get_objects():<br>/* for depsgraph.c, runs py expr once to collect all refs. made<br> * to objects (self refs. to the object that owns the py driver<br> * are not allowed). */
<br><br>I suspect that what is happening is that each pydriver can only have one 'self' object reference, and since in my case only one pydriver exists (since there's only one ipo, on one shape key, on one mesh that's linked), the self object gets evaluated only once.
<br><br>Can anyone confirm or deny that this is how it works? I couldn't find any documentation on it other than the commit log, which is reproduced (with errors!) in the 2.44 release notes.<br><br>Is this a limitation of pydrivers? Or the depgraph? Anyone know of any workarounds, or whether it's possible to fix? Thanks very much for your help.
<br><br>cheers,<br><br>Matt<br><br>PS. Originally in the pydriver I wrote just "Modifier.Settings.OBJECT", which gave an error "NameError: name 'Modifier' is not defined". Antont suggested I use 
Blender.Modifier.Settings.OBJECT which works fine. I think it would be a good idea to have the Modifier module (and others?) auto-imported for pydrivers.<br>