-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddon.py
More file actions
54 lines (41 loc) · 1.46 KB
/
addon.py
File metadata and controls
54 lines (41 loc) · 1.46 KB
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
from __future__ import annotations
import os
from typing import TYPE_CHECKING
import bpy
from bpy.types import Context
if TYPE_CHECKING:
from .preferences import OnScreenNumpadPreferences
from .utils.logging import get_logger
ADDON_PATH = os.path.dirname(os.path.abspath(__file__))
def get_prefs(context: Context = None) -> "OnScreenNumpadPreferences":
"""
Get addon preferences
Args:
context: Blender context (optional, defaults to bpy.context)
Returns:
OnScreenNumpadPreferences: Addon preferences
Raises:
KeyError: If addon preferences cannot be accessed
"""
if context is None:
context = bpy.context
try:
return context.preferences.addons[__package__].preferences
except KeyError:
raise KeyError(f"Addon preferences for '{__package__}' not found")
def init_addon():
"""Initialize addon settings after registration"""
try:
prefs = get_prefs()
log = get_logger()
if prefs.debug_mode:
log.set_level("debug")
log.info("On-Screen Numpad initialized with debug mode enabled")
else:
log.set_level("info")
log.info("On-Screen Numpad initialized")
except:
# If preferences not available yet, default to info level
log = get_logger()
log.set_level("info")
log.info("On-Screen Numpad initialized with default settings")