Addons: "persistent" parameter for addon_utils.enable(), so that you can enable
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Sat, 28 Apr 2012 09:00:09 +0000 (09:00 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Sat, 28 Apr 2012 09:00:09 +0000 (09:00 +0000)
addons from a startup script and keep them enabled after loading .blend files.

release/scripts/modules/addon_utils.py

index 588c10eea540a99b2639e0c9ac6362eaf3f9c142..695bb8cb6b626358c4f1cae09100644ac0bd8803 100644 (file)
@@ -212,10 +212,13 @@ def check(module_name):
 
         loaded_state = False
 
+    if mod and getattr(mod, "__addon_persistent__", False):
+        loaded_default = True
+
     return loaded_default, loaded_state
 
 
-def enable(module_name, default_set=True):
+def enable(module_name, default_set=True, persistent=False):
     """
     Enables an addon by name.
 
@@ -283,6 +286,7 @@ def enable(module_name, default_set=True):
             ext.module = module_name
 
     mod.__addon_enabled__ = True
+    mod.__addon_persistent__ = persistent
 
     if _bpy.app.debug_python:
         print("\taddon_utils.enable", mod.__name__)
@@ -305,6 +309,7 @@ def disable(module_name, default_set=True):
     # the addon in the user prefs.
     if mod:
         mod.__addon_enabled__ = False
+        mod.__addon_persistent = False
 
         try:
             mod.unregister()