Python addon_utils.modules() Examples
The following are 23
code examples of addon_utils.modules().
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: addon_updater.py From CrowdMaster with GNU General Public License v3.0 | 6 votes |
def reload_addon(self): # if post_update false, skip this function # else, unload/reload addon & trigger popup if self._auto_reload_post_update == False: print("Restart blender to reload addon and complete update") return if self._verbose:print("Reloading addon...") addon_utils.modules(refresh=True) bpy.utils.refresh_script_paths() # not allowed in restricted context, such as register module # toggle to refresh bpy.ops.wm.addon_disable(module=self._addon_package) bpy.ops.wm.addon_refresh() bpy.ops.wm.addon_enable(module=self._addon_package) # ------------------------------------------------------------------------- # Other non-api functions and setups # -------------------------------------------------------------------------
Example #2
Source File: addon_updater.py From Sorcar with GNU General Public License v3.0 | 6 votes |
def reload_addon(self): # if post_update false, skip this function # else, unload/reload addon & trigger popup if self._auto_reload_post_update == False: print("Restart blender to reload addon and complete update") return if self._verbose: print("Reloading addon...") addon_utils.modules(refresh=True) bpy.utils.refresh_script_paths() # not allowed in restricted context, such as register module # toggle to refresh bpy.ops.wm.addon_disable(module=self._addon_package) bpy.ops.wm.addon_refresh() bpy.ops.wm.addon_enable(module=self._addon_package) # ------------------------------------------------------------------------- # Other non-api functions and setups # -------------------------------------------------------------------------
Example #3
Source File: addon_updater.py From Blender-WMO-import-export-scripts with GNU General Public License v3.0 | 6 votes |
def reload_addon(self): # if post_update false, skip this function # else, unload/reload addon & trigger popup if self._auto_reload_post_update == False: print("Restart blender to reload addon and complete update") return if self._verbose:print("Reloading addon...") addon_utils.modules(refresh=True) bpy.utils.refresh_script_paths() # not allowed in restricted context, such as register module # toggle to refresh bpy.ops.wm.addon_disable(module=self._addon_package) bpy.ops.wm.addon_refresh() bpy.ops.wm.addon_enable(module=self._addon_package) # ------------------------------------------------------------------------- # Other non-api functions and setups # -------------------------------------------------------------------------
Example #4
Source File: op_UPDATE.py From BakeMyScan with GNU General Public License v3.0 | 6 votes |
def do_request(): loop = asyncio.get_event_loop() future = loop.run_in_executor(None, requests.get, 'https://api.github.com/repos/norgeotloic/BakeMyScan/releases') response = await future object = json.loads(response.text) bpy.types.Scene.newVersion = object[0]["tag_name"] for mod in addon_utils.modules(): if mod.bl_info.get("name") == "BakeMyScan": bpy.types.Scene.currentVersion = ".".join([str(x) for x in mod.bl_info.get("version")]) if bpy.types.Scene.currentVersion == bpy.types.Scene.newVersion: print("No new updates") else: print("A new update is available") print("%s -> %s" % (bpy.types.Scene.currentVersion, bpy.types.Scene.newVersion)) for a in object[0]["assets"]: if a["name"] == "BakeMyScan.zip": bpy.types.Scene.update_url = a["browser_download_url"] print(bpy.types.Scene.update_url)
Example #5
Source File: addon_updater.py From material-combiner-addon with MIT License | 6 votes |
def reload_addon(self): # if post_update false, skip this function # else, unload/reload addon & trigger popup if self._auto_reload_post_update is False: print("Restart blender to reload addon and complete update") return if self._verbose: print("Reloading addon...") addon_utils.modules(refresh=True) bpy.utils.refresh_script_paths() # not allowed in restricted context, such as register module # toggle to refresh bpy.ops.wm.addon_disable(module=self._addon_package) bpy.ops.wm.addon_refresh() bpy.ops.wm.addon_enable(module=self._addon_package) # ------------------------------------------------------------------------- # Other non-api functions and setups # -------------------------------------------------------------------------
Example #6
Source File: addon_updater.py From blender-addon-updater with GNU General Public License v3.0 | 6 votes |
def reload_addon(self): # if post_update false, skip this function # else, unload/reload addon & trigger popup if self._auto_reload_post_update == False: print("Restart blender to reload addon and complete update") return if self._verbose: print("Reloading addon...") addon_utils.modules(refresh=True) bpy.utils.refresh_script_paths() # not allowed in restricted context, such as register module # toggle to refresh bpy.ops.wm.addon_disable(module=self._addon_package) bpy.ops.wm.addon_refresh() bpy.ops.wm.addon_enable(module=self._addon_package) # ------------------------------------------------------------------------- # Other non-api functions and setups # -------------------------------------------------------------------------
Example #7
Source File: addon_updater.py From object_alignment with GNU General Public License v3.0 | 6 votes |
def reload_addon(self): # if post_update false, skip this function # else, unload/reload addon & trigger popup if self._auto_reload_post_update == False: print("Restart blender to reload addon and complete update") return if self._verbose: print("Reloading addon...") addon_utils.modules(refresh=True) bpy.utils.refresh_script_paths() # not allowed in restricted context, such as register module # toggle to refresh bpy.ops.wm.addon_disable(module=self._addon_package) bpy.ops.wm.addon_refresh() bpy.ops.wm.addon_enable(module=self._addon_package) # ------------------------------------------------------------------------- # Other non-api functions and setups # -------------------------------------------------------------------------
Example #8
Source File: addon_updater.py From archipack with GNU General Public License v3.0 | 6 votes |
def reload_addon(self): # if post_update false, skip this function # else, unload/reload addon & trigger popup if self._auto_reload_post_update == False: print("Restart blender to reload addon and complete update") return if self._verbose:print("Reloading addon...") addon_utils.modules(refresh=True) bpy.utils.refresh_script_paths() # not allowed in restricted context, such as register module # toggle to refresh bpy.ops.wm.addon_disable(module=self._addon_package) bpy.ops.wm.addon_refresh() bpy.ops.wm.addon_enable(module=self._addon_package) # ------------------------------------------------------------------------- # Other non-api functions and setups # -------------------------------------------------------------------------
Example #9
Source File: addon_updater.py From coa_tools with GNU General Public License v3.0 | 6 votes |
def reload_addon(self): # if post_update false, skip this function # else, unload/reload addon & trigger popup if self._auto_reload_post_update == False: print("Restart blender to reload addon and complete update") return if self._verbose: print("Reloading addon...") addon_utils.modules(refresh=True) bpy.utils.refresh_script_paths() # not allowed in restricted context, such as register module # toggle to refresh bpy.ops.wm.addon_disable(module=self._addon_package) bpy.ops.wm.addon_refresh() bpy.ops.wm.addon_enable(module=self._addon_package) # ------------------------------------------------------------------------- # Other non-api functions and setups # -------------------------------------------------------------------------
Example #10
Source File: addon_updater.py From kaleidoscope with GNU General Public License v3.0 | 6 votes |
def reload_addon(self): # if post_update false, skip this function # else, unload/reload addon & trigger popup if self._auto_reload_post_update == False: print("Restart blender to reload addon and complete update") return if self._verbose: print("Reloading addon...") addon_utils.modules(refresh=True) bpy.utils.refresh_script_paths() # not allowed in restricted context, such as register module # toggle to refresh bpy.ops.wm.addon_disable(module=self._addon_package) bpy.ops.wm.addon_refresh() bpy.ops.wm.addon_enable(module=self._addon_package) # ------------------------------------------------------------------------- # Other non-api functions and setups # -------------------------------------------------------------------------
Example #11
Source File: wm.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def execute(self, context): import addon_utils module_name = self.module modules = addon_utils.modules(refresh=False) mod = addon_utils.addons_fake_modules.get(module_name) if mod is not None: info = addon_utils.module_bl_info(mod) info["show_expanded"] = True bpy.context.user_preferences.active_section = 'ADDONS' context.window_manager.addon_filter = 'All' context.window_manager.addon_search = info["name"] bpy.ops.screen.userpref_show('INVOKE_DEFAULT') return {'FINISHED'} # Note: shares some logic with WM_OT_addon_install # but not enough to de-duplicate. Fixes here may apply to both.
Example #12
Source File: space_fluid_info.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def draw(self, context): layout = self.layout userpref = context.user_preferences used_ext = {ext.module for ext in userpref.addons} for mod in addon_utils.modules(refresh=False): if mod.bl_info["category"] == "Fluid Designer": module_name = mod.__name__ is_enabled = module_name in used_ext if is_enabled: layout.operator("wm.addon_disable", icon='CHECKBOX_HLT', text=mod.bl_info["name"], emboss=False).module = module_name else: layout.operator("wm.addon_enable", icon='CHECKBOX_DEHLT', text=mod.bl_info["name"], emboss=False).module = module_name layout.separator() layout.operator("wm.save_userpref", text="Save User Settings")
Example #13
Source File: space_fluid_file.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def draw(self, context): import addon_utils layout = self.layout userpref = context.user_preferences used_ext = {ext.module for ext in userpref.addons} for mod in addon_utils.modules(refresh=False): if mod.bl_info['category'] == 'Library Add-on': if mod.__name__ in used_ext: layout.operator('wm.addon_disable',text=mod.bl_info["name"],icon='CHECKBOX_HLT').module = mod.__name__ else: layout.operator('wm.addon_enable',text=mod.bl_info["name"],icon='CHECKBOX_DEHLT').module = mod.__name__ layout.separator() layout.operator('wm.save_userpref',text="Save User Preferences",icon='FILE_TICK') #------REGISTER
Example #14
Source File: misc_INFO_MT_help.py From Blender-CM3D2-Converter with Apache License 2.0 | 6 votes |
def execute(self, context): import addon_utils my_info = None for module in addon_utils.modules(): info = addon_utils.module_bl_info(module) if info['name'] == common.addon_name: my_info = info break area = common.get_request_area(context, 'USER_PREFERENCES') if area and my_info: context.user_preferences.active_section = 'ADDONS' context.window_manager.addon_search = my_info['name'] context.window_manager.addon_filter = 'All' if 'COMMUNITY' not in context.window_manager.addon_support: context.window_manager.addon_support = {'OFFICIAL', 'COMMUNITY'} if not my_info['show_expanded']: bpy.ops.wm.addon_expand(module=__name__.split('.')[0]) else: self.report(type={'ERROR'}, message="表示できるエリアが見つかりませんでした") return {'CANCELLED'} return {'FINISHED'}
Example #15
Source File: wm.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def path_from_addon(module): import os import addon_utils for mod in addon_utils.modules(): if mod.__name__ == module: filepath = mod.__file__ if os.path.exists(filepath): if os.path.splitext(os.path.basename(filepath))[0] == "__init__": return os.path.dirname(filepath), True else: return filepath, False return None, False
Example #16
Source File: optimization.py From cats-blender-plugin with MIT License | 5 votes |
def check_for_smc(): global draw_smc_ui, old_smc_version, smc_is_disabled, found_very_old_smc draw_smc_ui = None found_very_old_smc = False for mod in addon_utils.modules(): if mod.bl_info['name'] == "Shotariya-don": if hasattr(bpy.context.scene, 'shotariya_tex_idx'): found_very_old_smc = True continue if mod.bl_info['name'] == "Shotariya's Material Combiner": # print(mod.__name__, mod.bl_info['version']) # print(addon_utils.check(mod.__name__)) if mod.bl_info['version'] < (2, 1, 1, 2): old_smc_version = True # print('TOO OLD!') continue if not addon_utils.check(mod.__name__)[0]: smc_is_disabled = True # print('DISABLED!') continue # print('FOUND!') old_smc_version = False smc_is_disabled = False found_very_old_smc = False draw_smc_ui = getattr(import_module(mod.__name__ + '.operators.ui.include'), 'draw_ui') break # @register_wrap # class AtlasList(bpy.types.UIList): # def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index): # mat = item.material # row = layout.row() # row.prop(mat, 'name', emboss=False, text='', icon_value=layout.icon(mat)) # sub_row = row.row() # sub_row.scale_x = 0.2 # row.prop(mat, 'add_to_atlas', text='')
Example #17
Source File: reportError.py From object_alignment with GNU General Public License v3.0 | 5 votes |
def __init__(self): # get version and github_path for mod in addon_utils.modules(): if mod.bl_info.get("name", "") == addon_name: self.version = mod.bl_info.get("version", "") self.github_path = mod.bl_info.get("tracker_url", "") break self.txt_name = addon_name + "_error_report.txt" #############################################
Example #18
Source File: wm.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def path_from_addon(module): import os import addon_utils for mod in addon_utils.modules(): if mod.__name__ == module: filepath = mod.__file__ if os.path.exists(filepath): if os.path.splitext(os.path.basename(filepath))[0] == "__init__": return os.path.dirname(filepath), True else: return filepath, False return None, False
Example #19
Source File: __init__.py From Sorcar with GNU General Public License v3.0 | 5 votes |
def register(): print("-------------REGISTER SORCAR-------------") path = repr([i for i in addon_utils.modules() if i.bl_info['name'] == "Sorcar"][0]).split("from '")[1].split("__init__.py'>")[0] classes_ops = import_ops(path) classes_sockets = import_sockets(path) classes_ui = import_ui(path) classes_nodes = import_nodes(path) global all_classes, addon_keymaps all_classes = [ScNodeTree] all_classes.extend(classes_ops) all_classes.extend(classes_sockets) all_classes.extend(classes_ui) all_classes.append(SorcarPreferences) total_nodes = 0 node_categories = [] for cat in classes_nodes: total_nodes += len(classes_nodes[cat]) node_categories.append(ScNodeCategory(identifier="sc_"+cat, name=bpy.path.display_name(cat), items=[NodeItem(i.bl_idname) for i in classes_nodes[cat]])) all_classes.extend(classes_nodes[cat]) for i in all_classes: bpy.utils.register_class(i) nodeitems_utils.register_node_categories("sc_node_categories", node_categories) if not (update_each_frame in bpy.app.handlers.frame_change_post): bpy.app.handlers.frame_change_post.append(update_each_frame) if (not bpy.app.background): km, kmi = init_keymaps() for k in kmi: k.active = True addon_keymaps.append((km, k)) addon_updater_ops.register(bl_info) print_log("REGISTERED", msg="{} operators, {} sockets, {} UI, {} keymaps & {} nodes ({} categories)".format(len(classes_ops), len(classes_sockets), len(classes_ui), len(addon_keymaps), total_nodes, len(classes_nodes)))
Example #20
Source File: __init__.py From Fluid-Designer with GNU General Public License v3.0 | 4 votes |
def register(): from bpy.utils import register_class for mod in _modules_loaded: for cls in mod.classes: register_class(cls) # space_userprefs.py from bpy.props import StringProperty, EnumProperty from bpy.types import WindowManager def addon_filter_items(self, context): import addon_utils items = [('All', "All", "All Add-ons"), ('User', "User", "All Add-ons Installed by User"), ('Enabled', "Enabled", "All Enabled Add-ons"), ('Disabled', "Disabled", "All Disabled Add-ons"), ] items_unique = set() for mod in addon_utils.modules(refresh=False): info = addon_utils.module_bl_info(mod) items_unique.add(info["category"]) items.extend([(cat, cat, "") for cat in sorted(items_unique)]) return items WindowManager.addon_search = StringProperty( name="Search", description="Search within the selected filter", options={'TEXTEDIT_UPDATE'}, ) WindowManager.addon_filter = EnumProperty( items=addon_filter_items, name="Category", description="Filter add-ons by category", ) WindowManager.addon_support = EnumProperty( items=[('OFFICIAL', "Official", "Officially supported"), ('COMMUNITY', "Community", "Maintained by community developers"), ('TESTING', "Testing", "Newly contributed scripts (excluded from release builds)") ], name="Support", description="Display support level", default={'OFFICIAL', 'COMMUNITY'}, options={'ENUM_FLAG'}, ) # done...
Example #21
Source File: __init__.py From Fluid-Designer with GNU General Public License v3.0 | 4 votes |
def register(): bpy.utils.register_module(__name__) # space_userprefs.py from bpy.props import StringProperty, EnumProperty from bpy.types import WindowManager def addon_filter_items(self, context): import addon_utils items = [('All', "All", "All Add-ons"), ('User', "User", "All Add-ons Installed by User"), ('Enabled', "Enabled", "All Enabled Add-ons"), ('Disabled', "Disabled", "All Disabled Add-ons"), ] items_unique = set() for mod in addon_utils.modules(refresh=False): info = addon_utils.module_bl_info(mod) items_unique.add(info["category"]) items.extend([(cat, cat, "") for cat in sorted(items_unique)]) return items WindowManager.addon_search = StringProperty( name="Search", description="Search within the selected filter", options={'TEXTEDIT_UPDATE'}, ) WindowManager.addon_filter = EnumProperty( items=addon_filter_items, name="Category", description="Filter add-ons by category", ) WindowManager.addon_support = EnumProperty( items=[('OFFICIAL', "Official", "Officially supported"), ('COMMUNITY', "Community", "Maintained by community developers"), ('TESTING', "Testing", "Newly contributed scripts (excluded from release builds)") ], name="Support", description="Display support level", default={'OFFICIAL', 'COMMUNITY'}, options={'ENUM_FLAG'}, ) # done...
Example #22
Source File: GUI.py From BakeMyScan with GNU General Public License v3.0 | 4 votes |
def draw(self, context): self.layout.operator("wm.url_open", text="bakemyscan.org", icon_value=bpy.types.Scene.custom_icons["bakemyscan"].icon_id).url = "http://bakemyscan.org" #Update _text = "Check for updates" _operator = "bakemyscan.check_updates" if bpy.types.Scene.currentVersion is not None and bpy.types.Scene.newVersion is not None: if bpy.types.Scene.currentVersion == bpy.types.Scene.newVersion and not bpy.types.Scene.restartRequired: _text = "Nothing new. Check again?" _operator = "bakemyscan.check_updates" elif bpy.types.Scene.restartRequired: _text = "Restart blender to update" _operator = "wm.quit_blender" else: _text = "Update to %s" % bpy.types.Scene.newVersion _operator = "bakemyscan.update" else: pass row = self.layout.row(align=True) row.operator(_operator, text=_text, icon="FILE_REFRESH") for mod in addon_utils.modules(): if mod.bl_info.get("name") == "BakeMyScan": try: if bpy.types.Scene.currentVersion != bpy.types.Scene.newVersion: row.operator("wm.url_open", text="Changelog", icon="INFO").url = "https://github.com/norgeotloic/BakeMyScan/releases/latest" else: name = ".".join([str(x) for x in mod.bl_info.get("version")]) icon = bpy.types.Scene.custom_icons["bakemyscan"].icon_id row.operator("wm.url_open", icon="INFO", text='Current: %s' % name, icon_value=icon).url = "https://github.com/norgeotloic/BakeMyScan/releases/tag/"+name except: name = ".".join([str(x) for x in mod.bl_info.get("version")]) icon = bpy.types.Scene.custom_icons["bakemyscan"].icon_id row.operator("wm.url_open", icon="INFO", text='Current: %s' % name, icon_value=icon).url = "https://github.com/norgeotloic/BakeMyScan/releases/tag/"+name self.layout.label("Resources") self.layout.operator("wm.url_open", text="Tutorials", icon="QUESTION").url = "http://bakemyscan.org/tutorials" self.layout.operator("wm.url_open", text="BlenderArtists", icon="BLENDER").url = "https://blenderartists.org/t/bakemyscan-open-source-toolbox-for-asset-optimization" self.layout.operator("wm.url_open", text="Sketchfab", icon_value=bpy.types.Scene.custom_icons["sketchfab"].icon_id).url = "https://sketchfab.com/norgeotloic" self.layout.operator("wm.url_open", text="Twitter", icon_value=bpy.types.Scene.custom_icons["tweeter"].icon_id).url = "https://twitter.com/norgeotloic" self.layout.operator("wm.url_open", text="Youtube", icon_value=bpy.types.Scene.custom_icons["youtube"].icon_id).url = "https://youtube.com/norgeotloic" self.layout.label("Development") self.layout.operator("wm.url_open", text="Github", icon_value=bpy.types.Scene.custom_icons["github"].icon_id).url = "http://github.com/norgeotloic/BakeMyScan" self.layout.operator("wm.url_open", text="Build status", icon_value=bpy.types.Scene.custom_icons["travis"].icon_id).url = "https://travis-ci.org/norgeotloic/BakeMyScan" self.layout.operator("wm.url_open", text="Roadmap", icon="SORTTIME").url = "http://github.com/norgeotloic/BakeMyScan/milestones" self.layout.operator("wm.url_open", text='"Blog"', icon="WORDWRAP_ON").url = "http://bakemyscan.org/blog" self.layout.label("External software") self.layout.operator("wm.url_open", text="MMGtools", icon_value=bpy.types.Scene.custom_icons["mmg"].icon_id).url = "https://www.mmgtools.org/" self.layout.operator("wm.url_open", text="Instant Meshes", icon_value=bpy.types.Scene.custom_icons["instant"].icon_id).url = "https://github.com/wjakob/instant-meshes" self.layout.operator("wm.url_open", text="Quadriflow", icon="MOD_DECIM").url = "https://github.com/hjwdzh/QuadriFlow" self.layout.operator("wm.url_open", text="Meshlab", icon_value=bpy.types.Scene.custom_icons["meshlab"].icon_id).url = "http://www.meshlab.net/" self.layout.operator("wm.url_open", text="Colmap", icon="CAMERA_DATA").url = "https://colmap.github.io/" self.layout.operator("wm.url_open", text="OpenMVS", icon="CAMERA_DATA").url = "http://cdcseacave.github.io/openMVS/" #Main menu fonctions
Example #23
Source File: utils.py From Fluid-Designer with GNU General Public License v3.0 | 4 votes |
def enable_addons(addons=None, support=None, disable=False, check_only=False): """ Enable (or disable) addons based either on a set of names, or a set of 'support' types. Returns the list of all affected addons (as fake modules)! If "check_only" is set, no addon will be enabled nor disabled. """ import addon_utils if addons is None: addons = {} if support is None: support = {} userpref = bpy.context.user_preferences used_ext = {ext.module for ext in userpref.addons} ret = [mod for mod in addon_utils.modules() if ((addons and mod.__name__ in addons) or (not addons and addon_utils.module_bl_info(mod)["support"] in support))] if not check_only: for mod in ret: module_name = mod.__name__ if disable: if module_name not in used_ext: continue print(" Disabling module ", module_name) bpy.ops.wm.addon_disable(module=module_name) else: if module_name in used_ext: continue print(" Enabling module ", module_name) bpy.ops.wm.addon_enable(module=module_name) # XXX There are currently some problems with bpy/rna... # *Very* tricky to solve! # So this is a hack to make all newly added operator visible by # bpy.types.OperatorProperties.__subclasses__() for cat in dir(bpy.ops): cat = getattr(bpy.ops, cat) for op in dir(cat): getattr(cat, op).get_rna() return ret ##### Main Classes #####