5
$\begingroup$

In my Blender installation I have an addon registered, but when I ship my entire Blender folder to another developer (installed into a different path) it appears that the addon is not registered.

Perhaps addon registry records my full path and this is why my friend doesn't have it registered?

Is there a way to programatically register an addon in Python? Alternatively, can the --addon command line switch register?

$\endgroup$
  • 1
    $\begingroup$ Found the answer! bpy.ops.wm.addon_enable(module='<name of addon>') $\endgroup$ – Jeepster Feb 10 '14 at 20:05
1
$\begingroup$

Whether an addon is enabled or not, is stored in the local userpref.blend file. It is a user setting. It is not supposed to be carried around with individual .blend files (and may be seen as security issue if violated).

You find the preferences .blend in your user folder, on Windows %appdata%\Blender Foundation\Blender\2.69\config\userpref.blend (replace 2.69 by your current version number). If you use a portable Blender, then it's located in Blender\2.69\config\userpref.blend (with the Blender executable in Blender\).

If you wanna let a friend try your addon, send him the single .py file, or zip the python module and let him install it via File > User Preferences > Addons > Install from file... (he/she may enable it and save user settings to enable it by default).

$\endgroup$
7
$\begingroup$

To answer the specific question, I think you're looking for this: https://www.blender.org/api/blender_python_api_2_57_release/bpy.ops.wm.html#bpy.ops.wm.addon_enable

A colleague of mine and I are using this to setup Blender for command line user within Docker containers, in order to setup a scalable Blender render farm.

Your user would only have to run blender at the command line once and point to .py script that registers your add-on. Maybe you can make a shell file for this purpose. I am using Ubuntu so for me this might look like:

#!/usr/bin/env bash
blender --background --python /path/to/your/file.py
echo "Done"
$\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.