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

90 lines
1.9 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 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