2
$\begingroup$

I am trying to animate a Blender file from the command line that is using a couple of Python functions for Drivers. However, the command gives the following error, and consequently does not perform the animations.

    $ blender -b QCM.blend -y
read blend: /home/brent/Downloads/QCM/QCM.blend

Error in Driver: The following Python expression failed:
    'crystal_driver(frame)'

Traceback (most recent call last):
  File "<bpy driver>", line 1, in <module>
NameError: name 'crystal_driver' is not defined

Error in Driver: The following Python expression failed:
    'film_driver(frame)'

Traceback (most recent call last):
  File "<bpy driver>", line 1, in <module>
NameError: name 'film_driver' is not defined

If I run the file without the background switch, the animation works as expected:

$blender -y QCM.blend
read blend: /home/brent/Downloads/QCM/QCM.blend

Here is a screen shot of the script file in Blender, which shows the register box is checked. screen shot of Blender script file for Driver

Someone else appears to have a similar problem, but no solutions were proposed. https://www.reddit.com/r/blender/comments/2xhouc/driver_function_not_running_from_command_line/

$\endgroup$
4
  • $\begingroup$ Hi, it appears to be the order of loading when running in bg mode. The registered text block is run after the drivers , which invalidates them. In my sound drivers addon I have a drivers manager that seeks out all drivers in a blend, and have discovered you can re-validate them. Addons are run before the drivers even in bg mode, so one solution is to move your code to a simple addon and enable it, or re-validate your drivers in the text-block, eg ob.animation_data.drivers[0].driver.is_valid = True, or if you are interested comment here & I'll upload addon with fix $\endgroup$ – batFINGER Aug 27 '15 at 11:10
  • 1
    $\begingroup$ Ran it past Aligorith and ideasman42 on IRC reported as bug developer.blender.org/T45926 $\endgroup$ – batFINGER Aug 27 '15 at 12:36
  • $\begingroup$ They move quickly. Get a build from builder.blender.org/download & Bob's your uncle. $\endgroup$ – batFINGER Aug 27 '15 at 15:13
  • $\begingroup$ Thank you for the quick reply. I tried to make the script an addon by making a class and putting in the register()... etc function, but got a "NameError: name 'ob' is not defined" after enabling the addon and restarting blender. The error seems like it is probably related to the "ob" in your other method. I'll have to read more on addons, and start another question if I can't get it. I'll also try the most current build when it finishes loading. Lots to learn from your suggestion, including the phrase "Bob's your uncle". Thank you again. $\endgroup$ – BrentJM Aug 28 '15 at 1:32

Your Answer

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

Browse other questions tagged or ask your own question.