def execute(self, context): user_preferences = context.user_preferences addon_prefs = user_preferences.addons[__name__].preferences # mmvt_root = os.path.abspath(addon_prefs.mmvt_folder) mmvt_root = bpy.path.abspath(addon_prefs.mmvt_folder) print('mmvt_root: {}'.format(mmvt_root)) sys.path.append(mmvt_root) import mmvt_addon # If you change the code and rerun the addon, you need to reload MMVT_Addon imp.reload(mmvt_addon) print(mmvt_addon) mmvt_addon.main(addon_prefs) return {'FINISHED'}
def init_mmvt_addon(mmvt_addon_fol=''): # To run this function from command line: # 1) Copy the empty_subject.blend file, and rename to subject-name_atlas-name.blend # 2) Change the directory to the mmvt/src/mmvt_addon # 3) run: blender_path/blender /mmvt_path/subject-name_atlas-name.blend --background --python scripts/create_new_subject.py if mmvt_addon_fol == '': mmvt_addon_fol = get_mmvt_addon_dir() print('mmvt_addon_fol: {}'.format(mmvt_addon_fol)) sys.path.append(mmvt_addon_fol) import mmvt_addon # imp.reload(mmvt_addon) addon_prefs = Bag({'python_cmd':sys.executable, 'freeview_cmd':'freeview', 'freeview_cmd_verbose':True, 'freeview_cmd_stdin':True}) mmvt_addon.main(addon_prefs) bpy.context.window.screen = bpy.data.screens['Neuro'] return mmvt_addon
def init_mmvt_addon(mmvt_addon_fol=''): # To run this function from command line: # 1) Copy the empty_subject.blend file, and rename to subject-name_atlas-name.blend # 2) Change the directory to the mmvt/src/mmvt_addon # 3) run: blender_path/blender /mmvt_path/subject-name_atlas-name.blend --background --python scripts/create_new_subject.py if mmvt_addon_fol == '': mmvt_addon_fol = get_mmvt_addon_dir() print('mmvt_addon_fol: {}'.format(mmvt_addon_fol)) sys.path.append(mmvt_addon_fol) import mmvt_addon # if bpy.context.scene.mmvt_initialized: # print('mmvt was already initialized') # return mmvt_addon # imp.reload(mmvt_addon) addon_prefs = Bag({'python_cmd':sys.executable, 'freeview_cmd':'freeview', 'freeview_cmd_verbose':True, 'freeview_cmd_stdin':True}) mmvt_addon.main(addon_prefs) bpy.context.window.screen = bpy.data.screens['Neuro'] return mmvt_addon
import bpy import sys import importlib as imp # https://blenderartists.org/forum/archive/index.php/t-365581.html module = 'mmvt_loader' bpy.ops.wm.addon_enable(module=module) user_preferences = bpy.context.user_preferences addon_prefs = user_preferences.addons[module].preferences mmvt_root = bpy.path.abspath(addon_prefs.mmvt_folder) print('mmvt_root: {}'.format(mmvt_root)) sys.path.append(mmvt_root) import mmvt_addon # In case you want to debug, unmark the following two lines # from scripts import scripts_utils as su # su.debug() imp.reload(mmvt_addon) mmvt_addon.main(addon_prefs)