3

I've heard of PyDrivers where you can put python code into a driver, & I'm wondering, how would you do that in blender 2.7x without resorting to a lower blender version?

Here's what I'd like to put in the driver:

(ob(‘Armature’).getPose().bones[‘Bone.001’].head - ob(‘Armature’).getPose().bones[‘Bone’].head).length/250
gandalf3
  • 157,169
  • 58
  • 601
  • 1,133
ISaenz
  • 41
  • 2

1 Answers1

8

your example can be implemented as in the following driver :

enter image description here

but for more complex drivers refer to this DOC page , the important part is that you can define your function and add it to driver namespace as in this example :

import bpy

def driverFunc(val):

    return val * val    # return val squared

bpy.app.driver_namespace['driverFunc'] = driverFunc    # add function to driver_namespace

now you can use it the driver scripted expression

gandalf3
  • 157,169
  • 58
  • 601
  • 1,133
Chebhou
  • 19,533
  • 51
  • 98