This commit is contained in:
2025-11-24 22:26:56 +08:00
parent e4c713035b
commit 719058ff01
8 changed files with 310 additions and 33 deletions

View File

@@ -25,20 +25,42 @@ Studio Library 2.20.2
## 使用方法
### 在 Python 中启动
### 方式 1使用 launcher推荐
```python
from animation_tools.studiolibrary import launcher
launcher.LaunchStudioLibrary()
```
### 方式 2直接导入
```python
# 需要先添加路径到 sys.path
import sys
import os
studiolibrary_path = r'h:\Workspace\Raw\Tools\Plugins\Maya\2023\scripts\animation_tools\studiolibrary'
if studiolibrary_path not in sys.path:
sys.path.insert(0, studiolibrary_path)
# 然后导入并启动
import studiolibrary
studiolibrary.main()
```
### 方式 3从 animation_tools 导入
```python
# 如果 animation_tools 已在 PYTHONPATH 中
from animation_tools import studiolibrary
studiolibrary.main()
```
### 在 MEL 中启动
```mel
python("from animation_tools.studiolibrary import launcher; launcher.LaunchStudioLibrary()");
```
### 从工具架启动
点击动画工具架上的 **StudioLib** 按钮即可启动。
@@ -62,9 +84,15 @@ studiolibrary.main()
## 🔧 版本兼容性
### 支持的 Maya 版本
- **Maya 2017+** - 支持所有现代版本的 Maya
- **Maya 2017-2024** - 使用 PySide2
- **Maya 2025+** - 使用 PySide6
- **自动适配** - 运行时自动检测 Maya 环境和 Qt 版本
### Maya 2025 特别说明
- ✅ 已创建外层 `__init__.py` 文件,解决模块导入问题
- ✅ 自动检测并使用 PySide6
- ✅ 完全兼容新版本的 Python 3.11
### Qt 兼容性
Studio Library 使用 `Qt.py` 兼容层,支持多种 Qt 绑定:
- **PySide6** - Maya 2025+ (优先)

View File

@@ -0,0 +1,89 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Studio Library Wrapper Module
用于简化 Studio Library 的导入和使用
支持 Maya 2017-2026+ 所有版本
"""
import sys
import os
# 获取当前目录
_current_dir = os.path.dirname(os.path.abspath(__file__))
# 确保所有子模块路径都在 sys.path 中
_required_paths = [
_current_dir,
os.path.join(_current_dir, 'studiolibrary'),
os.path.join(_current_dir, 'studiolibrarymaya'),
os.path.join(_current_dir, 'mutils'),
os.path.join(_current_dir, 'studioqt'),
os.path.join(_current_dir, 'studiovendor'),
]
for _path in _required_paths:
if _path not in sys.path:
sys.path.insert(0, _path)
# 从内层 studiolibrary 模块导入所有功能
try:
from studiolibrary import (
__version__,
version,
config,
resource,
Library,
LibraryItem,
main,
)
# 导入工具函数
from studiolibrary.utils import *
# 导出所有公共接口
__all__ = [
'__version__',
'version',
'config',
'resource',
'Library',
'LibraryItem',
'main',
]
except ImportError as e:
import traceback
print("Failed to import studiolibrary:")
print(traceback.format_exc())
raise
def show(*args, **kwargs):
"""
便捷函数:启动 Studio Library
Args:
*args: 传递给 main() 的位置参数
**kwargs: 传递给 main() 的关键字参数
Returns:
LibraryWindow: Studio Library 窗口实例
"""
return main(*args, **kwargs)
def isMaya():
"""
检查是否在 Maya 环境中运行
Returns:
bool: 如果在 Maya 中返回 True否则返回 False
"""
try:
import maya.cmds
maya.cmds.about(batch=True)
return True
except ImportError:
return False

View File

@@ -4,7 +4,7 @@
"""
Studio Library Launcher
用于从工具架快速启动 Studio Library
支持所有 Maya 版本
支持所有 Maya 版本2017-2026+
"""
import sys
@@ -15,6 +15,9 @@ def LaunchStudioLibrary():
"""
启动 Studio Library 主界面
自动检测 Maya 版本和 Qt 绑定
Returns:
LibraryWindow: Studio Library 窗口实例,失败时返回 None
"""
try:
# 获取 Studio Library 路径
@@ -24,17 +27,28 @@ def LaunchStudioLibrary():
if current_dir not in sys.path:
sys.path.insert(0, current_dir)
# 导入并启动 Studio Library
import studiolibrary
# 确保子模块路径也在 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("Running in Maya environment")
print("Studio Library: Running in Maya environment")
else:
print("Running in standalone mode")
print("Studio Library: Running in standalone mode")
# 启动主窗口
window = studiolibrary.main()
@@ -47,6 +61,15 @@ def LaunchStudioLibrary():
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