72 lines
2.3 KiB
Python
72 lines
2.3 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
IK/FK Switcher 测试脚本
|
|
在 Maya 中运行此脚本来测试模块是否正常工作
|
|
"""
|
|
|
|
def test_ik_fk_switcher():
|
|
"""测试 ik_fk_switcher 模块的导入和函数"""
|
|
print("=" * 60)
|
|
print("IK/FK Switcher 测试")
|
|
print("=" * 60)
|
|
|
|
try:
|
|
# 测试导入
|
|
print("\n[1/5] 测试导入模块...")
|
|
import animation_tools.ik_fk_switcher as ikfk
|
|
print("✓ 成功导入 ik_fk_switcher")
|
|
|
|
# 测试 __all__ 导出
|
|
print("\n[2/5] 检查 __all__ 导出列表...")
|
|
if hasattr(ikfk, '__all__'):
|
|
print(f"✓ __all__ = {ikfk.__all__}")
|
|
else:
|
|
print("✗ 没有找到 __all__")
|
|
|
|
# 测试主要函数
|
|
print("\n[3/5] 检查主要函数...")
|
|
functions = ['fk_to_ik', 'ik_to_fk', 'delete_setup', 'documentation', 'extraOptions', 'user_interface', 'show']
|
|
for func_name in functions:
|
|
if hasattr(ikfk, func_name):
|
|
func = getattr(ikfk, func_name)
|
|
print(f"✓ {func_name}: {type(func)}")
|
|
else:
|
|
print(f"✗ {func_name}: 未找到")
|
|
|
|
# 测试 show() 函数
|
|
print("\n[4/5] 测试 show() 函数...")
|
|
if hasattr(ikfk, 'show') and callable(ikfk.show):
|
|
print("✓ show() 函数可调用")
|
|
print(f" 文档: {ikfk.show.__doc__}")
|
|
else:
|
|
print("✗ show() 函数不可用")
|
|
|
|
# 测试 dir()
|
|
print("\n[5/5] 列出所有可用属性...")
|
|
all_attrs = [attr for attr in dir(ikfk) if not attr.startswith('_')]
|
|
print(f"✓ 共有 {len(all_attrs)} 个公共属性/函数")
|
|
print(f" 主要函数: {[attr for attr in all_attrs if callable(getattr(ikfk, attr))][:10]}")
|
|
|
|
print("\n" + "=" * 60)
|
|
print("所有测试通过!")
|
|
print("=" * 60)
|
|
print("\n使用方法:")
|
|
print(" import animation_tools.ik_fk_switcher as ikfk")
|
|
print(" ikfk.show() # 启动 UI")
|
|
print("=" * 60)
|
|
|
|
return True
|
|
|
|
except Exception as e:
|
|
print(f"\n✗ 测试失败: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
return False
|
|
|
|
|
|
if __name__ == "__main__":
|
|
# 在 Maya 中运行
|
|
test_ik_fk_switcher()
|