Python addon_utils.enable() Examples

The following are 11 code examples of addon_utils.enable(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module addon_utils , or try the search function .
Example #1
Source File: helpers.py    From Fluid-Designer with GNU General Public License v3.0 6 votes vote down vote up
def _setup_addons(self):
        import sys
        import os

        sys_path = []
        if self.addon_paths is not None:
            for path in self.addon_paths():
                if path not in sys.path:
                    sys.path.append(path)

        import addon_utils
        addons = []
        if self.addons is not None:
            addons.extend(self.addons())
            for addon in addons:
                addon_utils.enable(addon)

        self._addon_store = {
            "sys_path": sys_path,
            "addons": addons,
        } 
Example #2
Source File: importer.py    From cats-blender-plugin with MIT License 6 votes vote down vote up
def execute(self, context):
        Common.remove_unused_objects()

        # Make sure that the first layer is visible
        if hasattr(context.scene, 'layers'):
            context.scene.layers[0] = True

        # Enable fbx if it isn't enabled yet
        fbx_is_enabled = addon_utils.check('io_scene_fbx')[1]
        if not fbx_is_enabled:
            addon_utils.enable('io_scene_fbx')

        try:
            bpy.ops.import_scene.fbx('INVOKE_DEFAULT',
                                     automatic_bone_orientation=False,
                                     use_prepost_rot=False,
                                     use_anim=False)
        except (TypeError, ValueError):
            bpy.ops.import_scene.fbx('INVOKE_DEFAULT')

        return {'FINISHED'} 
Example #3
Source File: importer.py    From cats-blender-plugin with MIT License 6 votes vote down vote up
def draw(self, context):
        layout = self.layout
        col = layout.column(align=True)

        # row = col.row(align=True)
        # row.label(text="The plugin 'XPS Tools' is required for this function.")
        col.separator()
        row = col.row(align=True)
        row.label(text="If it is not enabled please enable it in your User Preferences.")
        row = col.row(align=True)
        row.label(text="If it is not installed please download and install it manually.")
        col.separator()
        col.separator()
        row = col.row(align=True)
        row.label(text="Make sure to install the version for Blender " + current_blender_version, icon="INFO")
        col.separator()
        row = col.row(align=True)
        row.operator(XpsToolsButton.bl_idname, icon=globs.ICON_URL) 
Example #4
Source File: importer.py    From cats-blender-plugin with MIT License 6 votes vote down vote up
def draw(self, context):
        layout = self.layout
        col = layout.column(align=True)

        # row = col.row(align=True)
        # row.label(text="The plugin 'Source Tools' is required for this function.")
        col.separator()
        row = col.row(align=True)
        row.label(text="If it is not enabled please enable it in your User Preferences.")
        row = col.row(align=True)
        row.label(text="If it is not installed please download and install it manually.")
        col.separator()
        col.separator()
        row = col.row(align=True)
        row.label(text="Make sure to install the version for Blender " + current_blender_version, icon="INFO")
        col.separator()
        row = col.row(align=True)
        row.operator(SourceToolsButton.bl_idname, icon=globs.ICON_URL) 
Example #5
Source File: importer.py    From cats-blender-plugin with MIT License 6 votes vote down vote up
def draw(self, context):
        layout = self.layout
        col = layout.column(align=True)

        # row = col.row(align=True)
        # row.label(text="The plugin 'VRM Importer' is required for this function.")
        col.separator()
        row = col.row(align=True)
        row.label(text="If it is not enabled please enable it in your User Preferences.")
        row = col.row(align=True)
        row.label(text="Currently you have to select 'Testing' in the addons settings.")
        col.separator()
        row = col.row(align=True)
        row.label(text="If it is not installed please download and install it manually.")
        col.separator()
        row = col.row(align=True)
        row.operator(VrmToolsButton.bl_idname, icon=globs.ICON_URL) 
Example #6
Source File: wm.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def execute(self, context):
        import addon_utils

        err_str = ""

        def err_cb(ex):
            import traceback
            nonlocal err_str
            err_str = traceback.format_exc()
            print(err_str)

        mod = addon_utils.enable(self.module, default_set=True, handle_error=err_cb)

        if mod:
            info = addon_utils.module_bl_info(mod)

            info_ver = info.get("blender", (0, 0, 0))

            if info_ver > bpy.app.version:
                self.report({'WARNING'},
                            ("This script was written Blender "
                             "version %d.%d.%d and might not "
                             "function (correctly), "
                             "though it is enabled" %
                             info_ver))
            return {'FINISHED'}
        else:

            if err_str:
                self.report({'ERROR'}, err_str)

            return {'CANCELLED'} 
Example #7
Source File: wm.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def execute(self, context):
        import addon_utils

        err_str = ""

        def err_cb(ex):
            import traceback
            nonlocal err_str
            err_str = traceback.format_exc()
            print(err_str)

        mod = addon_utils.enable(self.module, default_set=True, handle_error=err_cb)

        if mod:
            info = addon_utils.module_bl_info(mod)

            info_ver = info.get("blender", (0, 0, 0))

            if info_ver > bpy.app.version:
                self.report({'WARNING'},
                            ("This script was written Blender "
                             "version %d.%d.%d and might not "
                             "function (correctly), "
                             "though it is enabled" %
                             info_ver))
            return {'FINISHED'}
        else:

            if err_str:
                self.report({'ERROR'}, err_str)

            return {'CANCELLED'} 
Example #8
Source File: utils.py    From blender-retarget with MIT License 5 votes vote down vote up
def setUp(self):
        self._reports = []
        bpy.ops.wm.read_homefile()
        addon_utils.enable('animation_retarget', default_set=True) 
Example #9
Source File: op_REMESHERS_POST.py    From BakeMyScan with GNU General Public License v3.0 5 votes vote down vote up
def remesh(self, context):
        lr = self.copiedobject
        hr = self.initialobject

        if self.manifold_method == "print3d":
            isloaded = addon_utils.check("object_print3d_utils")[0]
            if not isloaded:
                addon_utils.enable("object_print3d_utils")
            bpy.ops.mesh.print3d_clean_non_manifold()
            if not isloaded:
                addon_utils.disable("object_print3d_utils")

        elif self.manifold_method == "fill":
            bpy.ops.object.editmode_toggle()
            bpy.ops.mesh.select_mode(type="EDGE")
            bpy.ops.mesh.select_all(action='DESELECT')
            bpy.ops.mesh.select_non_manifold()
            bpy.ops.mesh.fill()
            bpy.ops.object.editmode_toggle()

        elif self.manifold_method == "manifold":
            self.report({"ERROR"}, "Manifold is not implemented yet")
            return {"CANCELLED"}

        elif self.manifold_method == "meshlab":
            self.report({"ERROR"}, "Meshlab manifolding is not implemented yet")
            return {"CANCELLED"}

        return {"FINISHED"} 
Example #10
Source File: Renderer.py    From BlenderProc with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, config):
        Module.__init__(self, config)
        self._avoid_rendering = config.get_bool("avoid_rendering", False)
        addon_utils.enable("render_auto_tile_size") 
Example #11
Source File: importer.py    From cats-blender-plugin with MIT License 4 votes vote down vote up
def draw(self, context):
        layout = self.layout
        col = layout.column(align=True)

        row = col.row(align=True)
        row.label(text="The plugin 'mmd_tools' is required for this function.")
        row = col.row(align=True)
        row.label(text="Please restart Blender.")


# def popup_install_xps(self, context):
#     layout = self.layout
#     col = layout.column(align=True)
#
#     row = col.row(align=True)
#     row.label(text="The plugin 'XPS Tools' is required for this function.")
#     col.separator()
#     row = col.row(align=True)
#     row.label(text="If it is not enabled please enable it in your User Preferences.")
#     row = col.row(align=True)
#     row.label(text="If it is not installed please click here to download it and then install it manually.")
#     col.separator()
#     row = col.row(align=True)
#     row.operator('importer.download_xps_tools', icon=globs.ICON_URL)
#
#
# def popup_install_source(self, context):
#     layout = self.layout
#     col = layout.column(align=True)
#
#     row = col.row(align=True)
#     row.label(text="The plugin 'Blender Source Tools' is required for this function.")
#     col.separator()
#     row = col.row(align=True)
#     row.label(text="If it is not enabled please enable it in your User Preferences.")
#     row = col.row(align=True)
#     row.label(text="If it is not installed please click here to download it and then install it manually.")
#     col.separator()
#     row = col.row(align=True)
#     row.operator('importer.download_source_tools', icon=globs.ICON_URL)
#
#
# def popup_install_vrm(self, context):
#     layout = self.layout
#     col = layout.column(align=True)
#
#     row = col.row(align=True)
#     row.label(text="The plugin 'VRM Importer' is required for this function.")
#     col.separator()
#     row = col.row(align=True)
#     row.label(text="If it is not enabled please enable it in your User Preferences.")
#     row = col.row(align=True)
#     row.label(text="Currently you have to select 'Testing' in the addons settings")
#     row = col.row(align=True)
#     row.label(text="If it is not installed please click here to download it and then install it manually.")
#     col.separator()
#     row = col.row(align=True)
#     row.operator('importer.download_vrm', icon=globs.ICON_URL)