Python源码示例:addon.enable()
示例1
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,
}
示例2
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'}
示例3
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)
示例4
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)
示例5
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)
示例6
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'}
示例7
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'}
示例8
def setUp(self):
self._reports = []
bpy.ops.wm.read_homefile()
addon_utils.enable('animation_retarget', default_set=True)
示例9
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"}
示例10
def __init__(self, config):
Module.__init__(self, config)
self._avoid_rendering = config.get_bool("avoid_rendering", False)
addon_utils.enable("render_auto_tile_size")
示例11
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)