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