[Bf-python] Py Drivers - Possible feature enhancement.

Martin Poirier theeth at yahoo.com
Thu Nov 22 18:52:45 CET 2007


--- Campbell Barton <ideasman42 at gmail.com> wrote:

> Cessen and I were talking about possible PyDriver
> enhancements, One
> problem at the moment is the difficulty in
> referencing a bone or even
> an object.
> To reference a posebone for instance...
> 
>  ob['someObject']
> 
> Since cessen also does lots of rigging related
> stuff, to get a posebone...
> 
>  ob['someObject'].getPose().bones['someBone']
> 
> If you want 2 posebones, this gets really long to
> type in.
> 
> One possible solution would be to have the driver
> object and bone
> options (that are normally there) - also there with
> pydrivers. this
> could be given a name like var1 for the pydrivers,
> this would need to
> be clear from the interface.
> 
> An issue is that you might want any number of
> objects/bones
> references, at the moment the interface only allows
> for 1, maybe for
> this we could have 2 object and bone inputs.
> 
> Of course this would not change how existing scripts
> work, and you
> could always refer to a 3rd item the existing way,
> this would just
> allow referring to objects/bones much more easily,
> and using the
> existing bone selection method.
> 
> It also has the advantage that renaming an object
> wont mess up the
> pyDriver since blender references the object (not
> its name)
> 
> Any opinions on this?, Id like to try adding it.

PyDrivers where never made for complex cases. In those
case, it'd be better if the driver could just
reference an external script that would define a more
complex function.

You could have a file defining multiple functions and
then calling them from a pydriver:

driver("filename").foo(arguments)

driver would basically import the file as a module and
return it. In python, that would be:

def driver(name):
    exec "import %s as module" % name
    return module

As argument, you could give the current object/bone or
whatnot, so the same function can be reused.

Martin


      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs



More information about the Bf-python mailing list