|
1 | | -# BLUI v0.8.2 |
| 1 | +# BLUI v0.8.3 |
2 | 2 |
|
3 | | -import bpy |
| 3 | +import bpy, os, urllib.request, addon_utils |
4 | 4 | from bpy.app.handlers import persistent |
5 | 5 |
|
| 6 | +@persistent |
| 7 | +def load_handler_for_preferences(_): |
| 8 | + print("Changing Preference Defaults!") |
| 9 | + #from . import BLUI_Keymap |
| 10 | + |
| 11 | + string = bpy.app.version_string |
| 12 | + blenderversion = string.rstrip(string[-2:]) |
| 13 | + keymap_filepath = str(os.path.expanduser('~/AppData/Roaming/Blender Foundation/Blender/')) + blenderversion + str('/scripts/startup/bl_app_templates_user/BLUI/BLUI_Keymap.py') |
| 14 | + |
| 15 | + bpy.ops.preferences.keyconfig_import(filepath=keymap_filepath) |
| 16 | + bpy.ops.preferences.keyconfig_activate(filepath=keymap_filepath) |
| 17 | + |
6 | 18 | @persistent |
7 | 19 | def load_handler_for_startup(_): |
8 | 20 | print("Changing Startup Defaults!") |
9 | 21 |
|
| 22 | + prefs = bpy.context.preferences |
| 23 | + active_addons = prefs.addons |
| 24 | + |
| 25 | + addons = [] |
| 26 | + addon = { |
| 27 | + 'addon_name':'', |
| 28 | + 'url':'', |
| 29 | + } |
| 30 | + |
| 31 | + addon1 = addon.copy() |
| 32 | + addon1['addon_name'] = 'MrMannequinsTools' |
| 33 | + addon1['url'] = 'https://github.com/Jim-Kroovy/Mr-Mannequins-Tools/releases/download/v1.4/MrMannequinsTools-1.4.zip' |
| 34 | + |
| 35 | + addon2 = addon.copy() |
| 36 | + addon2['addon_name'] = 'blender-for-unrealengine' |
| 37 | + addon2['url'] = 'https://github.com/xavier150/Blender-For-UnrealEngine-Addons/releases/download/v0.2.8/blender-for-unrealengine.zip' |
| 38 | + |
| 39 | + addon3 = addon.copy() |
| 40 | + addon3['addon_name'] = 'TexTools_1_4_4' |
| 41 | + addon3['url'] = 'https://github.com/SavMartin/TexTools-Blender/releases/download/v1.4.4/TexTools_1_4_4.zip' |
| 42 | + |
| 43 | + addon4 = addon.copy() |
| 44 | + addon4['addon_name'] = 'modifier_stack_manager' |
| 45 | + addon4['url'] = 'https://github.com/salaivv/modifier-stack-manager/releases/download/0.2/modifier_stack_manager.zip' |
| 46 | + |
| 47 | + addon5 = addon.copy() |
| 48 | + addon5['addon_name'] = 'RightMouseNavigation' |
| 49 | + addon5['url'] = 'https://github.com/SpectralVectors/RightMouseNavigation/releases/download/1.8/RightMouseNavigation.zip' |
| 50 | + |
| 51 | + addon6 = addon.copy() |
| 52 | + addon6['addon_name'] = 'CommentBox-main' |
| 53 | + addon6['url'] = 'https://github.com/SpectralVectors/CommentBox/archive/refs/heads/main.zip' |
| 54 | + |
| 55 | + for addon in active_addons: |
| 56 | + |
| 57 | + if addon_utils.check('MrMannequinsTools') == (True, False): |
| 58 | + addons.append(addon1) |
| 59 | + |
| 60 | + if addon_utils.check('blender-for-unrealengine') == (True, False): |
| 61 | + addons.append(addon2) |
| 62 | + |
| 63 | + if addon_utils.check('TexTools_1_4_4') == (True, False): |
| 64 | + addons.append(addon3) |
| 65 | + |
| 66 | + if addon_utils.check('modifier_stack_manager') == (True, False): |
| 67 | + addons.append(addon4) |
| 68 | + |
| 69 | + if addon_utils.check('RightMouseNavigation') == (True, False): |
| 70 | + addons.append(addon5) |
| 71 | + |
| 72 | + if addon_utils.check('CommentBox-main') == (True, False): |
| 73 | + addons.append(addon6) |
| 74 | + |
| 75 | + for addon in addons: |
| 76 | + url_file = bpy.path.basename(addon['url']) |
| 77 | + module_name = bpy.path.display_name_from_filepath(addon['url']) |
| 78 | + filepath = str(os.path.expanduser('~/Downloads/') + url_file) |
| 79 | + file = urllib.request.urlretrieve(addon['url'], filepath) |
| 80 | + overwrite_setting = False |
| 81 | + bpy.ops.preferences.addon_install(overwrite=overwrite_setting, filepath=filepath) |
| 82 | + try: |
| 83 | + bpy.ops.preferences.addon_enable(module=module_name) |
| 84 | + except: # ModuleNotFoundError |
| 85 | + bpy.ops.preferences.addon_enable(module=addon['addon_name']) |
| 86 | + |
10 | 87 | bpy.ops.wm.splash('INVOKE_DEFAULT') |
11 | 88 |
|
12 | 89 | def register(): |
13 | 90 | print("Registering to Change Defaults") |
| 91 | + bpy.app.handlers.load_factory_preferences_post.append(load_handler_for_preferences) |
14 | 92 | bpy.app.handlers.load_factory_startup_post.append(load_handler_for_startup) |
15 | 93 |
|
16 | 94 |
|
17 | 95 | def unregister(): |
18 | 96 | print("Unregistering to Change Defaults") |
| 97 | + bpy.app.handlers.load_factory_preferences_post.remove(load_handler_for_preferences) |
19 | 98 | bpy.app.handlers.load_factory_startup_post.remove(load_handler_for_startup) |
0 commit comments