Update
This commit is contained in:
@@ -3,10 +3,10 @@
|
||||
|
||||
"""
|
||||
Studio Library Wrapper Module
|
||||
用于简化 Studio Library 的导入和使用
|
||||
支持 Maya 2017-2026+ 所有版本
|
||||
Simplify Studio Library import and usage
|
||||
Support Maya 2017-2026+ all versions
|
||||
|
||||
使用方法:
|
||||
Usage:
|
||||
import animation_tools.studiolibrary
|
||||
animation_tools.studiolibrary.show()
|
||||
"""
|
||||
@@ -14,36 +14,53 @@ Studio Library Wrapper Module
|
||||
import sys
|
||||
import os
|
||||
|
||||
# 获取当前目录
|
||||
# Get current directory
|
||||
_current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
# 全局变量用于存储导入的模块
|
||||
# Global variable to store imported module
|
||||
_studiolibrary_module = None
|
||||
__version__ = "2.20.2"
|
||||
|
||||
def _ensure_studiolibrary_loaded():
|
||||
"""确保 studiolibrary 模块已加载"""
|
||||
"""Ensure studiolibrary module is loaded"""
|
||||
global _studiolibrary_module
|
||||
|
||||
if _studiolibrary_module is not None:
|
||||
return _studiolibrary_module
|
||||
|
||||
# 添加所有必要的路径
|
||||
# Add all necessary paths
|
||||
_inner_studiolibrary = os.path.join(_current_dir, 'studiolibrary')
|
||||
for _subdir in ['studiolibrary', 'studiolibrarymaya', 'mutils', 'studioqt', 'studiovendor']:
|
||||
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)
|
||||
|
||||
# 导入 studiolibrary
|
||||
import studiolibrary
|
||||
_studiolibrary_module = studiolibrary
|
||||
# Import from inner studiolibrary by temporarily manipulating sys.path
|
||||
# Remove current directory to avoid circular import
|
||||
_saved_path = sys.path[:]
|
||||
if _current_dir in sys.path:
|
||||
sys.path.remove(_current_dir)
|
||||
|
||||
# Add inner studiolibrary to the front
|
||||
if _inner_studiolibrary not in sys.path:
|
||||
sys.path.insert(0, _inner_studiolibrary)
|
||||
|
||||
try:
|
||||
import studiolibrary
|
||||
_studiolibrary_module = studiolibrary
|
||||
finally:
|
||||
# Restore sys.path
|
||||
sys.path = _saved_path
|
||||
# But keep the inner studiolibrary path
|
||||
if _inner_studiolibrary not in sys.path:
|
||||
sys.path.insert(0, _inner_studiolibrary)
|
||||
|
||||
return _studiolibrary_module
|
||||
|
||||
def version():
|
||||
return __version__
|
||||
|
||||
# 导出所有公共接口
|
||||
# Export all public interfaces
|
||||
__all__ = [
|
||||
'__version__',
|
||||
'version',
|
||||
@@ -54,14 +71,14 @@ __all__ = [
|
||||
|
||||
def show(*args, **kwargs):
|
||||
"""
|
||||
便捷函数:启动 Studio Library
|
||||
Convenience function: Launch Studio Library
|
||||
|
||||
Args:
|
||||
*args: 传递给 main() 的位置参数
|
||||
**kwargs: 传递给 main() 的关键字参数
|
||||
*args: Positional arguments passed to main()
|
||||
**kwargs: Keyword arguments passed to main()
|
||||
|
||||
Returns:
|
||||
LibraryWindow: Studio Library 窗口实例
|
||||
LibraryWindow: Studio Library window instance
|
||||
|
||||
Example:
|
||||
>>> import animation_tools.studiolibrary
|
||||
@@ -72,14 +89,14 @@ def show(*args, **kwargs):
|
||||
|
||||
def main(*args, **kwargs):
|
||||
"""
|
||||
启动 Studio Library 主窗口
|
||||
Launch Studio Library main window
|
||||
|
||||
Args:
|
||||
*args: 传递给 main() 的位置参数
|
||||
**kwargs: 传递给 main() 的关键字参数
|
||||
*args: Positional arguments passed to main()
|
||||
**kwargs: Keyword arguments passed to main()
|
||||
|
||||
Returns:
|
||||
LibraryWindow: Studio Library 窗口实例
|
||||
LibraryWindow: Studio Library window instance
|
||||
"""
|
||||
lib = _ensure_studiolibrary_loaded()
|
||||
return lib.main(*args, **kwargs)
|
||||
@@ -87,10 +104,10 @@ def main(*args, **kwargs):
|
||||
|
||||
def isMaya():
|
||||
"""
|
||||
检查是否在 Maya 环境中运行
|
||||
Check if running in Maya environment
|
||||
|
||||
Returns:
|
||||
bool: 如果在 Maya 中返回 True,否则返回 False
|
||||
bool: True if in Maya, False otherwise
|
||||
"""
|
||||
try:
|
||||
import maya.cmds
|
||||
|
||||
Reference in New Issue
Block a user