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).

| improve this answer | |
$\endgroup$
6
$\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

For example:

import bpy
bpy.ops.wm.addon_install(filepath='/home/my-addons/awesome.py')
bpy.ops.wm.addon_enable(module='awesome')

Regarding the part of your posting where you say "when I ship my entire Blender folder to another developer" .. I suggest you make your solution turn-key and provide an install script that points blender to your .py file and registers needed addons. Maybe something along the lines of:

#!/usr/bin/env bash
blender --background --python /path/to/addon-installer.py
echo "Done"
| improve this answer | |
$\endgroup$
  • $\begingroup$ This is not helpful for installing addons, please refer to this answer: blender.stackexchange.com/questions/73759/… $\endgroup$ – Ahmed Ali Feb 11 at 15:45
  • $\begingroup$ Actually it is if one would take the time to follow the link ... however I went ahead and added a code example from my referenced link so its more complete. $\endgroup$ – StartupGuy Feb 18 at 1:42

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.