Update
This commit is contained in:
78
2025/scripts/animation_tools/studiolibrary/launcher.py
Normal file
78
2025/scripts/animation_tools/studiolibrary/launcher.py
Normal file
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Studio Library Launcher
|
||||
用于从工具架快速启动 Studio Library
|
||||
支持所有 Maya 版本(2017-2026+)
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
|
||||
def LaunchStudioLibrary():
|
||||
"""
|
||||
启动 Studio Library 主界面
|
||||
自动检测 Maya 版本和 Qt 绑定
|
||||
|
||||
Returns:
|
||||
LibraryWindow: Studio Library 窗口实例,失败时返回 None
|
||||
"""
|
||||
try:
|
||||
# 获取 Studio Library 路径
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
# 关键:直接将内层 studiolibrary 子目录放到 sys.path 最前面
|
||||
# 这样 import studiolibrary 会直接找到内层的,避免循环导入
|
||||
studiolibrary_subdir = os.path.join(current_dir, 'studiolibrary')
|
||||
|
||||
# 临时保存并清理 sys.path,避免外层包干扰
|
||||
original_path = sys.path[:]
|
||||
sys.path.insert(0, studiolibrary_subdir)
|
||||
|
||||
# 添加其他必要的路径
|
||||
for subdir in ['studiolibrarymaya', 'mutils', 'studioqt', 'studiovendor']:
|
||||
subdir_path = os.path.join(current_dir, subdir)
|
||||
if subdir_path not in sys.path:
|
||||
sys.path.insert(0, subdir_path)
|
||||
|
||||
# 导入 Studio Library(现在会找到内层的)
|
||||
import studiolibrary
|
||||
|
||||
# 打印版本信息
|
||||
print("Studio Library version: " + str(studiolibrary.version()))
|
||||
|
||||
# 检测 Maya 环境
|
||||
try:
|
||||
import maya.cmds
|
||||
maya.cmds.about(batch=True)
|
||||
print("Studio Library: Running in Maya environment")
|
||||
except (ImportError, AttributeError):
|
||||
print("Studio Library: Running in standalone mode")
|
||||
|
||||
# 启动主窗口
|
||||
window = studiolibrary.main()
|
||||
|
||||
print("Studio Library launched successfully")
|
||||
|
||||
return window
|
||||
|
||||
except Exception as e:
|
||||
print("Failed to launch Studio Library: " + str(e))
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
# 提供详细的调试信息
|
||||
print("\n=== Debug Information ===")
|
||||
print("Current directory: " + os.path.dirname(os.path.abspath(__file__)))
|
||||
print("sys.path entries:")
|
||||
for i, path in enumerate(sys.path[:10]):
|
||||
print(" [" + str(i) + "] " + path)
|
||||
print("=========================\n")
|
||||
|
||||
return None
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
LaunchStudioLibrary()
|
||||
Reference in New Issue
Block a user