3
$\begingroup$

I'd like to use the default studio light hdris in a script. I was going to create a custom path based of bpy.app.binary_path and then I realized that the storage location varies per operating system:

  • [WIN] - C:\Program Files\Blender Foundation\Blender <version>\<version>\Datafiles\Studiolights\World\
  • [OSX] - /Applications/Blender/Contents/Resources/<version>/Datafiles/Studiolights/World/
  • [Linux] - /opt/Blender <version>/<version>/Datafiles/Studiolights/World/

Q: Is there any way to get the filepaths of all the images in the world folder without hardcoding the folder paths?

$\endgroup$

1 Answer 1

3
$\begingroup$

You can get the filepaths via Preferences.studio_lights reference. I'd suggest use the python console to figure out:

>>> for i in C.preferences.studio_lights:
...     print(i.path)
...     

Output:

/Applications/Blender.app/Contents/Resources/<version>/datafiles/studiolights/studio/basic.sl
/Applications/Blender.app/Contents/Resources/<version>/datafiles/studiolights/matcap/basic_1.exr
/Applications/Blender.app/Contents/Resources/<version>/datafiles/studiolights/matcap/basic_2.exr
...

To filter the list and only get the filepaths of the hdris, you can use the StudioLight.type property:

>>> for i in C.preferences.studio_lights:
...     if i.type=='WORLD':
...         print (i.path)

Output:

/Applications/Blender.app/Contents/Resources/<version>/datafiles/studiolights/world/city.exr
/Applications/Blender.app/Contents/Resources/<version>/datafiles/studiolights/world/courtyard.exr
/Applications/Blender.app/Contents/Resources/<version>/datafiles/studiolights/world/forest.exr
...

List comprehension for convenience:

>>> [sl.path for sl in C.preferences.studio_lights if sl.type=='WORLD'] 

Related: How can I list all the matcaps and studio lights via python?

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .