Real Time pyDrivers ?


i need help (again…:rolleyes:) with pyDrivers…

In 2.49, i was able to use python driven drivers. I was a big fan of having external functions defined in a file within the .blend.

I struggle to replicate that with 2.5x.

OK there is this ('function')='function'

thing, but i don’t get them to work realtime…

Let us say i have a cube and a plane.
I want my plane’s scale to be driven by the cube’s position.
So i create a driver for plane.scale[0], set it to “scripted expression” and point to a function defined in a text file where my cube’s position is analysed and transformed, etc…

It’ll work when frames change, but not real time in the 3D window.

I want my plane to change size real-time when i move the cube. Is that possible ?

I think that is the way the 2.5 architecture works. One thing I do when dealing with drivers is to just hit the play button and set a small loop range. Then it will appear to work interactively.

Seriously ?
So it would appear to be a limitation of the driver system ?

I thought that was possible… really disappointed.

a sample blender-2.58.1 blend-file
with driver-function and real-time eval in 3D-view.

Its based on aligoriths blog:

blend-sample is short and simple,
a cube with driven z-scale by the distance of two spheres.
Distance of the 2 objects (spheres) is calculated by a python-function,
this registerd and put into the driver for the z-scale.

For realtime-update the 2 objects are enabled as vars in the driver,
but not used for calculation, only to force the update of the driver-eval.

— update, edit: I did not enable the python-script for auto-load,
i did not register it. So you have to run it with alt-p
and then again re-evaluate the driver-script-expression (it will
show the default error, because on loading the file the function is
not available = no auto-loading)


driverscript.blend (69.6 KB)

Hi Test-dr, and thanks for your help !

Nice example, i understand the use of vars better, but i still find this 2.5x way so much more cumbersome than old 2.49…
Just a file and off you go (or went…)

BTW, can you tell me how you make your script “auto-loadable” ? That would be very very nice if one didn’t have to refresh the driver’s expressions. My file will have more than 40 !

Cheers !

@test-dr: I just tried to load your BLEND file in 2.5.8 r38446 and it crashes blender on windows. I can not even look at the file.

@gwenouille: To make a script auto-run, name the script in the text window with a .py extension ( and check the Register button for the script in the text window. Then save the file. The next time you load the file it will be run automatically.

OK I’ll have a look at that later… I haven’t had any problems with the file with 2.58.0 r37702 BTW

Thanks !

OK I’ve played with your file and adapted mine: thanks for the tip about auto-loading scripts: very nice !

But seriously, this is just a pain in the butt to be honest… I went back to 2.49 with my same file, and everything works out of the box: no auto-loading scripts, and no variables, and yet it works real-time perfectly smoothly !

In my file i have 47 winglets whose rotational state depends on a command in my ship’s dashboard (as you’ll have guessed by now, this is a spare-time project: no urgency here). That means i have to define the same variable 47 times over? (and another 47 for the other side of the ship). I still don’t get the reason why we’d need these variables in the first place: 2.49 managed quite well without, didn’t it ?

I’d like to know more about these drivers, but the wiki is not explaining drivers altogether…

Do you know who to contact to know the reasons why we need to set up variables ?