Files
Nexus/2023/scripts/animation_tools/atools/__init__.py
2025-11-25 02:04:55 +08:00

104 lines
2.3 KiB
Python

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
aTools Wrapper Module
Simplify aTools import and usage without installation
Support Maya 2017-2026+ all versions
Usage:
import animation_tools.atools
animation_tools.atools.show()
"""
import sys
import os
# Get current directory
_current_dir = os.path.dirname(os.path.abspath(__file__))
# Global variable to store if aTools is loaded
_atools_loaded = False
__version__ = "2.0.0"
def _ensure_atools_loaded():
"""Ensure aTools module is loaded"""
global _atools_loaded
if _atools_loaded:
return True
# Add current directory (atools) to sys.path so modules can be imported
# This allows "from animTools.animBar import animBarUI" to work
if _current_dir not in sys.path:
sys.path.insert(0, _current_dir)
_atools_loaded = True
return True
def version():
"""Return aTools version"""
return __version__
# Export all public interfaces
__all__ = [
'__version__',
'version',
'show',
'launch',
]
def show(*args, **kwargs):
"""
Convenience function: Launch aTools Animation Bar
Args:
*args: Positional arguments passed to animBarUI.show()
**kwargs: Keyword arguments passed to animBarUI.show()
Returns:
Animation Bar window instance
Example:
>>> import animation_tools.atools
>>> animation_tools.atools.show()
"""
_ensure_atools_loaded()
try:
from animTools.animBar import animBarUI
return animBarUI.show(*args, **kwargs)
except ImportError as e:
print("Failed to import aTools: " + str(e))
print("Please make sure all aTools files are in the correct location")
return None
def launch(*args, **kwargs):
"""
Launch aTools Animation Bar (alias for show)
Args:
*args: Positional arguments passed to show()
**kwargs: Keyword arguments passed to show()
Returns:
Animation Bar window instance
"""
return show(*args, **kwargs)
def isMaya():
"""
Check if running in Maya environment
Returns:
bool: True if in Maya, False otherwise
"""
try:
import maya.cmds
maya.cmds.about(batch=True)
return True
except (ImportError, AttributeError):
return False