3
$\begingroup$

I run a small studio and we are looking into centralizing blender install.

OCIO and addons I can deal with a custom startup.py script that I launch when blender is started, but I cant find a way to add a custom asset library path, or font path or any of those paths, usually in other apps those would just be environment variables.

Is there a way to do it? Thank you!

$\endgroup$
1

1 Answer 1

1
$\begingroup$

Here's an asnwer for adding a list of Asset pathes:

if you need to erase the list of assets before just use this code

for i in range(len(bpy.context.preferences.filepaths.asset_libraries)):
   bpy.ops.preferences.asset_library_remove(index=0)

by default blender takes the name of the directory as Name:

1.if you want a different name for the Name : for each tupple in list_pathes just put in the tupple the name you want to appear in the list first and the path of the directory where is your blend file containing assets

list_pathes = [
("Zozo LE BOBO",
"D:\- 4. Software Data\- Blender\Assets Library\cs boulons vis et formes"),
("RAGNAGNA",
"D:\- 4. Software Data\- Blender\Assets Library\cs materials"),
("zglurb",
"D:\- 4. Software Data\- Blender\Assets Library\cs geometry nodes")
]


offset = len(bpy.context.preferences.filepaths.asset_libraries)
index = offset
for path in list_pathes:
    bpy.ops.preferences.asset_library_add(directory = path[1])
    # give a name to your asset dir
    bpy.context.preferences.filepaths.asset_libraries[index].name = path[0]
    index += 1

2.if you don't need a different name for your asset you can use this simple code

list_pathes = [
"D:\- 4. Software Data\- Blender\Assets Library\cs boulons vis et formes",
"D:\- 4. Software Data\- Blender\Assets Library\cs materials",
"D:\- 4. Software Data\- Blender\Assets Library\cs geometry nodes"
]
for path in list_pathes:
    bpy.ops.preferences.asset_library_add(directory = path)

3.if you don't need a different name for your asset and all your assets are in folders nested in one specific folder

path = "D:\- 4. Software Data\- Blender\Assets Library"
for i in os.scandir(path):
    if i.is_dir():
        print('Folder: ' + i.path)
        bpy.ops.preferences.asset_library_add(directory = i.path)    

 
$\endgroup$

You must log in to answer this question.

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