Files
Nexus/2023/scripts/animation_tools/studiolibrary/launcher.py
2025-11-24 22:26:56 +08:00

78 lines
2.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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__))
# 确保路径在 sys.path 中
if current_dir not in sys.path:
sys.path.insert(0, current_dir)
# 确保子模块路径也在 sys.path 中
studiolibrary_subdir = os.path.join(current_dir, 'studiolibrary')
if studiolibrary_subdir not in sys.path:
sys.path.insert(0, studiolibrary_subdir)
# 导入 Studio Library
try:
# 方式1直接从外层包导入
import studiolibrary
except ImportError:
# 方式2从子目录导入
sys.path.insert(0, studiolibrary_subdir)
import studiolibrary
# 打印版本信息
print(f"Studio Library version: {studiolibrary.version()}")
# 检测 Maya 环境
if studiolibrary.isMaya():
print("Studio Library: Running in Maya environment")
else:
print("Studio Library: Running in standalone mode")
# 启动主窗口
window = studiolibrary.main()
print("Studio Library launched successfully")
return window
except Exception as e:
print(f"Failed to launch Studio Library: {e}")
import traceback
traceback.print_exc()
# 提供详细的调试信息
print("\n=== Debug Information ===")
print(f"Current directory: {os.path.dirname(os.path.abspath(__file__))}")
print(f"sys.path entries:")
for i, path in enumerate(sys.path[:10]):
print(f" [{i}] {path}")
print("=========================\n")
return None
if __name__ == "__main__":
LaunchStudioLibrary()