From 693a9663b9fce6dff02904424e14632f0da4b062 Mon Sep 17 00:00:00 2001 From: Jeffreytsai1004 Date: Sun, 9 Feb 2025 23:46:33 +0800 Subject: [PATCH] Update --- scripts/__init__.py | 63 ++++++++++++++++++++++++++++++++++++++++++++- scripts/config.py | 23 +++++++++++++---- 2 files changed, 80 insertions(+), 6 deletions(-) diff --git a/scripts/__init__.py b/scripts/__init__.py index 3240337..52b35f8 100644 --- a/scripts/__init__.py +++ b/scripts/__init__.py @@ -1,4 +1,65 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from . import * \ No newline at end of file +import os +import sys +from . import config + +# 确保PYDNA_PATH在sys.path中 +if config.PYDNA_PATH not in sys.path: + sys.path.insert(0, config.PYDNA_PATH) # 将PYDNA_PATH添加到搜索路径的最前面 + +# 先导入dna模块 +try: + import dna +except ImportError as e: + # 更详细的错误信息 + print("="*80) + print("DNA模块导入失败:") + print(f"错误信息: {str(e)}") + print(f"PYDNA_PATH: {config.PYDNA_PATH}") + print(f"当前Python路径:") + for p in sys.path: + print(f" - {p}") + print("="*80) + + # 检查pydna目录是否存在及其内容 + if os.path.exists(config.PYDNA_PATH): + print(f"\nPYDNA目录内容:") + for root, dirs, files in os.walk(config.PYDNA_PATH): + print(f"\n目录: {root}") + for d in dirs: + print(f" 目录: {d}") + for f in files: + print(f" 文件: {f}") + else: + print(f"\nPYDNA目录不存在: {config.PYDNA_PATH}") + + raise + +# 现在导入其他模块 +from .api import build_meshes, build_rig +from .builder.config import Config, RigConfig +from .builder.maya.skin_weights import ( + get_skin_weights_from_scene, + set_skin_weights_to_scene, +) +from .dnalib.dnalib import DNA +from .dnalib.layer import Layer +from .MetaFusion import show +from .config import __version__ + +__all__ = [ + "DNA", + "build_rig", + "build_meshes", + "show", + "get_skin_weights_from_scene", + "set_skin_weights_to_scene", + "Config", + "RigConfig", + "Layer", + "__version__", +] + + diff --git a/scripts/config.py b/scripts/config.py index b417655..9558f30 100644 --- a/scripts/config.py +++ b/scripts/config.py @@ -9,7 +9,7 @@ import webbrowser import datetime import sys import os - +__version__ = "2.1.1" # Base Information TOOL_NAME = str("MetaFusion") TOOL_VERSION = str("Beta v1.0.0") @@ -31,10 +31,24 @@ BUILDER_PATH = str(os.path.join(SCRIPTS_PATH, "builder").replace("\\", "/")) DNALIB_PATH = str(os.path.join(SCRIPTS_PATH, "dnalib").replace("\\", "/")) UI_PATH = str(os.path.join(SCRIPTS_PATH, "ui").replace("\\", "/")) UTILS_PATH = str(os.path.join(SCRIPTS_PATH, "utils").replace("\\", "/")) -# System Information -SYSTEM_OS = str(sys.platform) -MAYA_VERSION = str(mel.eval("$gMAJOR.$gMINOR")) +def get_system_os(): + SYSTEM_OS = str(sys.platform) + """获取系统平台""" + if SYSTEM_OS == "win32": + return "Windows" + elif SYSTEM_OS == "linux": + return "Linux" + elif SYSTEM_OS == "darwin": + return "macOS" + else: + return SYSTEM_OS + +SYSTEM_OS = get_system_os() + +# 使用cmds.about()获取Maya版本 +MAYA_VERSION = str(cmds.about(version=True)) PYTHON_VERSION = str(f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}") + def get_python_version(): """获取Python版本目录名称""" version = sys.version_info @@ -120,7 +134,6 @@ if __name__ == "__main__": TOOL_STYLE_FILE, DNACALIB_PATH, BUILDER_PATH, - DNALIB_PATH, UI_PATH, UTILS_PATH,