2026-02-16
This commit is contained in:
@@ -1,5 +1,23 @@
|
||||
import bpy
|
||||
import math
|
||||
import os
|
||||
|
||||
try:
|
||||
from ..utils import get_addon_preferences
|
||||
except (ImportError, ValueError):
|
||||
# Fallback if import fails (e.g., when run as script)
|
||||
def get_addon_preferences():
|
||||
test_names = ["bl_ext.vscode_development.AmazonCharacterTools", "amzncharactertools", "AmazonCharacterTools"]
|
||||
for addon_name in test_names:
|
||||
addon_prefs = bpy.context.preferences.addons.get(addon_name)
|
||||
if addon_prefs and hasattr(addon_prefs, 'preferences') and hasattr(addon_prefs.preferences, 'amzn_bsdf_materials_path'):
|
||||
return addon_prefs.preferences
|
||||
# Search all addons
|
||||
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') and hasattr(addon_prefs.preferences, 'amzn_bsdf_materials_path'):
|
||||
return addon_prefs.preferences
|
||||
return None
|
||||
|
||||
def append_and_parent_device():
|
||||
# First, find and rename the existing Device to Device-Old
|
||||
@@ -31,8 +49,17 @@ def append_and_parent_device():
|
||||
old_parent_type = 'OBJECT'
|
||||
old_parent_bone = ''
|
||||
|
||||
# Append the new Device asset
|
||||
device_blend_path = r"A:\1 Amazon_Active_Projects\1 BlenderAssets\Amazon\device_v2.blend"
|
||||
# Get path from addon preferences
|
||||
prefs = get_addon_preferences()
|
||||
if not prefs:
|
||||
print("Error: Could not access addon preferences")
|
||||
return
|
||||
|
||||
device_blend_path = prefs.amzn_device_path
|
||||
|
||||
if not device_blend_path or not os.path.exists(device_blend_path):
|
||||
print(f"Error: Device library path not set or file not found: {device_blend_path}")
|
||||
return
|
||||
|
||||
# Append the Device object
|
||||
with bpy.data.libraries.load(device_blend_path, link=False) as (data_from, data_to):
|
||||
|
||||
Reference in New Issue
Block a user