forked from lunadigital/btoa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddon_preferences.py
62 lines (46 loc) · 1.86 KB
/
addon_preferences.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
import bpy
from bpy.types import AddonPreferences, Operator
from bpy.props import StringProperty, BoolProperty
import os
from . import environ as aienv
def refresh_addon(self, context):
prefs = bpy.context.preferences.addons[__package__].preferences
aienv.save_cached_arnold_path(prefs.arnold_path)
bpy.ops.preferences.addon_disable(module="btoa")
bpy.ops.preferences.addon_enable(module="btoa")
class ArnoldAddonPreferences(AddonPreferences):
bl_idname = __package__
arnold_path: StringProperty(
name="Arnold Path",
subtype="DIR_PATH",
update=refresh_addon
)
# Used to check if we need to unregister everything or just addon preferences
full_unregister: BoolProperty()
def draw(self, context):
# SDK config
box = self.layout.box()
row = box.row()
row.prop(self, "arnold_path")
row.enabled = not aienv.is_preconfigured()
row = box.row()
if aienv.is_preconfigured():
row.label(text="Path automatically set by $ARNOLD_ROOT")
# OCIO config notification
profile = "Filmic"
if os.getenv("OCIO") != aienv.get_default_ocio_config():
normalized_path = os.path.normpath(os.path.dirname(os.getenv("OCIO")))
profile = normalized_path.split(os.sep).pop()
box = self.layout.box()
col = box.column()
col.label(text="OCIO Color Management")
col.separator()
col.label(text="Active Config: {}".format(profile))
col.label(text="Config Path: {}".format(os.getenv("OCIO")))
if profile == "Filmic":
col.separator()
col.label(text="To use an OCIO config other than Filmic, point the OCIO environment variable to a valid OCIO config.")
classes = (
ArnoldAddonPreferences,
)
register, unregister = bpy.utils.register_classes_factory(classes)