2
$\begingroup$

I am constantly using new workstations where I have to install a new version of blender. While the blender cloud add-on allows one to sync settings between devices, it does not sync user-installed add-ons themselves. If I have all the add-ons I want to install in a folder I download form a cloud location, how could I create a script that would automatically install and activate them?

$\endgroup$
2
$\begingroup$

You can designate the folder with the scripts, create a list of files within this folder (i.e., directory), and use the wm.addon_install() command on each file. You can create a list of the module names you want to install, and then loop through them with wm.addon_enable()

import os
import bpy


# Define path to your downloaded script
path_to_script_dir = os.path('/Users/YourUserName/Downloads/scripts')

#Define a list of the files in this folder, i.e. directory. The method listdir() will return this list from our folder of downloaded scripts. 
file_list = sorted(os.listdir(path_to_script_dir))

#Further specificy that of this list of files, you only want the ones with the .zip extension.
script_list = [item for item in file_list if item.endswith('.zip')]

#Specify the file path of the individual scripts (their names joined with the location of your downloaded scripts folder) then use wm.addon_install() to install them. 
for file in file_list:
    path_to_file = os.path.join(path_to_script_dir, item)
    bpy.ops.wm.addon_install(overwrite=True, target='DEFAULT', filepath=path_to_file, filter_folder=True, filter_python=False, filter_glob="*.py;*.zip")

#Specify which add-ons you want enabled. For example, Crowd Render, Pie Menu Editor, etc. Use the script's python module. 
enableTheseAddons = ['crowdrender', 'pie_menu_editor', 'animation_nodes','blender_cloud']

#Use addon_enable() to enable them.
for string in enableTheseAddons: 
    name = enableTheseAddons
    bpy.ops.wm.addon_enable(module = string)
| 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.