7
$\begingroup$

Is it possible to write Multi-line drivers? As I understand it, drivers just assign the given statement to a variable, so you couldn't have _expressions (which don't evaluate to anything) in there. Is there some way to go around this? If so, how?

$\endgroup$
  • $\begingroup$ yes you can ( it was called pydriver) here blender.stackexchange.com/a/27056/5113 $\endgroup$ – Chebhou Jul 16 '15 at 23:11
  • $\begingroup$ @Chebhou is there a list of all the expressions that can be used in drivers like frame, floor, min, max? $\endgroup$ – Denis Jul 16 '15 at 23:20
  • 1
    $\begingroup$ @denis yes i'll add the link $\endgroup$ – Chebhou Jul 16 '15 at 23:21
  • $\begingroup$ Mostly-joking answer: github.com/csvoss/onelinerizer $\endgroup$ – wchargin Nov 5 '17 at 17:56
8
$\begingroup$

Although the expression is one line you can call a complex function in that line, you have to define and add this function to the driver's namespace before using it.

here's an example function and how it's added to the Driver's namespace ( from the DOC ) :

import bpy

def driverFunc(val):

    return val * val    # return val squared

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

To see the already availabe functions and properties type bpy.app.driver_namespace[' in the python console and hit Ctrl+space

DOC link for more info

$\endgroup$
  • $\begingroup$ To be a little more explicit: that python function should be entered into one of blender's Text Editor buffers and then click Run Script once, and then each time you alter the function. To make sure it runs every time you load the .blend file I think you have to name the text buffer with something ending in .py, and click the Register checkbox. $\endgroup$ – Mutant Bob Jul 17 '15 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.