How can my script be sure that some other script used gets loaded.

For now, I'm using addon_utils.enable("some_needed_addon") inside the register() function of init.py of my script

and addon_utils.disable("some_needed_addon") in the unregister()

and at the biginning or this init.py I have

if "bpy" in locals():
    import importlib

    import bpy
    import addon_utils # To use some other addons


With all that, when you call the new file command, the other script is no longer activated so it is not callable, because I didn't save it in user preferences and don't want to because I'm not sure user will want that.


If your add-on depends on another.

You can enable it from the script like this:

import addon_utils
addon_utils.enable("another_addon", default_set=False, persistent=True)
  • default_set: to leave the users preferences alone.
  • persistent: to keep the add-on loaded, even when the user runs File -> New.

This can be called from the register function.


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.