3
$\begingroup$

Are there any global variables in Blender? I was searching for them in Blender docs, but didn't find anything.

For example, I want to override the default /tmp directory with another directory. But I want to do it by overriding the environment variable.

For example Nuke has NUKE_TEMP_DIR variable, which I can simply override with a new value, and every time I start Nuke the temp directory will be as in the variable.

Houdini also has this kind of variables, Maya and so on.

What about Blender?

$\endgroup$
  • 4
    $\begingroup$ Go to Preferences > File and change the default paths you want. If you really need to set environment variables run: blender --help from command line and see the Environment Variables section. $\endgroup$ – Jaroslav Jerryno Novotny Nov 5 '18 at 13:26
6
$\begingroup$
Environment Variables:
  $BLENDER_USER_CONFIG      Directory for user configuration files.
  $BLENDER_USER_SCRIPTS     Directory for user scripts.
  $BLENDER_SYSTEM_SCRIPTS   Directory for system wide scripts.
  $BLENDER_USER_DATAFILES   Directory for user data files (icons, translations, ..).
  $BLENDER_SYSTEM_DATAFILES Directory for system wide data files.
  $BLENDER_SYSTEM_PYTHON    Directory for system python libraries.
  $TMP or $TMPDIR           Store temporary files here.
  $SDL_AUDIODRIVER          LibSDL audio driver - alsa, esd, dma.
  $PYTHONHOME               Path to the python directory, eg. /usr/lib/python.

But the best way is to modify your prefs (File->path) as said above.

| improve this answer | |
$\endgroup$
0
$\begingroup$

You can set any kind of variable to any type or any object in the manner of python's dictionary.

Try the following:

import bpy
bpy.context.scene['MyVar'] = 'this is my custom var'

just save the file and reopen that. check the variable:

bpy.context.scene['MyVar']

you will see the variable is stored!

| improve this answer | |
$\endgroup$

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.