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

101 lines
2.4 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 animation_tools.studiolibrary
animation_tools.studiolibrary.show()
"""
import sys
import os
# 获取当前目录
_current_dir = os.path.dirname(os.path.abspath(__file__))
# 全局变量用于存储导入的模块
_studiolibrary_module = None
__version__ = "2.20.2"
def _ensure_studiolibrary_loaded():
"""确保 studiolibrary 模块已加载"""
global _studiolibrary_module
if _studiolibrary_module is not None:
return _studiolibrary_module
# 添加所有必要的路径
_inner_studiolibrary = os.path.join(_current_dir, 'studiolibrary')
for _subdir in ['studiolibrary', '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)
# 导入 studiolibrary
import studiolibrary
_studiolibrary_module = studiolibrary
return _studiolibrary_module
def version():
return __version__
# 导出所有公共接口
__all__ = [
'__version__',
'version',
'show',
'main',
]
def show(*args, **kwargs):
"""
便捷函数:启动 Studio Library
Args:
*args: 传递给 main() 的位置参数
**kwargs: 传递给 main() 的关键字参数
Returns:
LibraryWindow: Studio Library 窗口实例
Example:
>>> import animation_tools.studiolibrary
>>> animation_tools.studiolibrary.show()
"""
lib = _ensure_studiolibrary_loaded()
return lib.main(*args, **kwargs)
def main(*args, **kwargs):
"""
启动 Studio Library 主窗口
Args:
*args: 传递给 main() 的位置参数
**kwargs: 传递给 main() 的关键字参数
Returns:
LibraryWindow: Studio Library 窗口实例
"""
lib = _ensure_studiolibrary_loaded()
return lib.main(*args, **kwargs)
def isMaya():
"""
检查是否在 Maya 环境中运行
Returns:
bool: 如果在 Maya 中返回 True否则返回 False
"""
try:
import maya.cmds
maya.cmds.about(batch=True)
return True
except (ImportError, AttributeError):
return False