3
$\begingroup$

I want to reload an addon using a script, however I cannot get the same functionality as pressing F8.

What I'm trying to do:

The addon manuelbastionilab (http://www.manuelbastioni.com/) has some .json files which specify how to change blendshapes to make certain expressions. If I modify such a .json, it is not detected in Blender. If I press F8, this addon with its .json files are reloaded and everything is good.

However, now I want to achieve the same functionality in a script.

What I tried

As suggest here: Is there a way to restart a modified addon? , I tried different combinations of (open Python console with Shift+F4):

bpy.utils.unregister_module('manuelbastionilab')
bpy.utils.register_module('manuelbastionilab')
bpy.ops.wm.addon_disable(module='manuelbastionilab')
bpy.ops.wm.addon_disable(module='manuelbastionilab')

But all didn't give the same functionality as F8. If I use one of these code lines in the build-in terminal in Blender, it does reload the addon, but the .json files are not reloaded.

I also tried import bge and then bge.events.F8KEY, but I get a NameError: name 'bge' is not defined.

Question

How do I get script-wise the exact same functionality as F8? But preferably only for 1 addon?

$\endgroup$
  • 3
    $\begingroup$ F8 is the equivalent of bpy.ops.script.reload() $\endgroup$ – batFINGER Dec 1 '17 at 10:48
1
$\begingroup$

The following worked for me in the Python console in Blender (Shift+F4 to open):

import imp
import manuelbastionilab  # addon name
imp.reload(manuelbastionilab)
bpy.ops.wm.addon_enable(module='manuelbastionilab')
$\endgroup$
  • $\begingroup$ Single line command for Blender 2.8 to reload 1 add-on: bpy.ops.preferences.addon_enable(module='manuelbastionilab') $\endgroup$ – NumesSanguis Apr 21 '19 at 5:30

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.