4
$\begingroup$

I understand you can put custom Python scripts in scripts/startup/ and they will be executed upon starting Blender.

However, I need to store my script outside of the Blender installation. With other software, such as Maya and Nuke, I can define an environment variable which will make those apps look for a script in a custom location and execute it during startup. Does Blender have anything like that?

EDIT: I can't open up the Blender UI and change options that way... as I'm talking about a deploy of Blender on many machines in a company. Therefore it has to be something which happens during the startup of Blender.

$\endgroup$
4
$\begingroup$

It seems that the best solution for me could be to execute blender with the --python <script.py> argument. The script will be executed at startup.

$\endgroup$
  • $\begingroup$ I just came to the same conclusion - but you beat me to it! Command line options can be viewed by running 'blender --help' and one of those is '--python'. Creating a file named 'blender_start.py' containing "import bpy; bpy.ops.mesh.primitive_cube_add()' and running 'blender --python blender_start.py' does indeed invoke the script (and create an additional cube primitive). $\endgroup$ – Rich Sedman Jan 11 '18 at 15:28
4
$\begingroup$

Go to File -> User Preferences and select the "File" tab. In the dialog, there is a "Scripts" entry where you can define the location of an alternative scripts directory.

If you want to deploy this change to a lot of blender installations, simply copy the userpref.blend file to your skeleton/template user home directory. Whenever a new user is created, this file will then be copied to his home directory, and when he starts blender, he'll have the changed script preference. The neat thing is that you can change other preferences values (and the startup blend file, too, if you want) with this. For Linux, the file lives under ~/.config/blender/blendversion/config/userpref.blend. I'm pretty sure that for Windows there is a similar file that gets stored somewhere in the user's homedir.

$\endgroup$
  • $\begingroup$ I added a comment on that I'm deploying Blender in my company on many machines, which makes it tedious to have to open up the Blender UI on all machines and change these options. $\endgroup$ – fredrik Jan 11 '18 at 14:44
  • $\begingroup$ I edited my answer accordingly. $\endgroup$ – Pascal Jan 11 '18 at 23:52

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.