33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
"""Utility functions for AMZN Character Tools."""
|
|
import bpy
|
|
|
|
|
|
def get_addon_preferences():
|
|
"""Get the addon preferences, finding the correct addon identifier automatically.
|
|
|
|
Returns:
|
|
The addon preferences object, or None if not found.
|
|
"""
|
|
# Try common identifiers first
|
|
test_names = [
|
|
"bl_ext.vscode_development.AmazonCharacterTools", # Extension format
|
|
"amzncharactertools", # Manifest ID
|
|
"AmazonCharacterTools", # Module name
|
|
]
|
|
|
|
for addon_name in test_names:
|
|
addon_prefs = bpy.context.preferences.addons.get(addon_name)
|
|
if addon_prefs and hasattr(addon_prefs, 'preferences'):
|
|
# Verify it's our preferences class
|
|
if hasattr(addon_prefs.preferences, 'amzn_bsdf_materials_path'):
|
|
return addon_prefs.preferences
|
|
|
|
# If not found, search all addons for one with our preferences
|
|
for addon_name in bpy.context.preferences.addons.keys():
|
|
addon_prefs = bpy.context.preferences.addons.get(addon_name)
|
|
if addon_prefs and hasattr(addon_prefs, 'preferences'):
|
|
if hasattr(addon_prefs.preferences, 'amzn_bsdf_materials_path'):
|
|
return addon_prefs.preferences
|
|
|
|
return None
|