#!/usr/bin/env python # -*- coding: utf-8 -*- import os import sys import maya.cmds as cmds import datetime # Base Information TOOL_NAME = str("MetaFusion") TOOL_VERSION = str("Beta v1.0.0") TOOL_AUTHOR = str("CGNICO") TOOL_LANG = str('en_US') TOOL_WSCL_NAME = str(f"{TOOL_NAME}WorkSpaceControl") TOOL_HELP_URL = str(f"https://gitea.cgnico.com/CGNICO/{TOOL_NAME}/wiki") TOOL_YEAR = str(datetime.datetime.now().year) # BASE_PATH TOOL_PATH = str(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))).replace("\\", "/")) SCRIPTS_PATH = str(os.path.join(TOOL_PATH, "scripts").replace("\\", "/")) # 资源路径 RESOURCES_PATH = str(os.path.join(TOOL_PATH, "resources").replace("\\", "/")) ICONS_PATH = str(os.path.join(RESOURCES_PATH, "icons").replace("\\", "/")) STYLES_PATH = str(os.path.join(RESOURCES_PATH, "styles").replace("\\", "/")) # DNA DNA_FILE_PATH = str(os.path.join(RESOURCES_PATH, "dna").replace("\\", "/")) DNA_IMG_PATH = str(os.path.join(RESOURCES_PATH, "img").replace("\\", "/")) DNA_VERSION = str("MH.4") LOD_LEVELS = range(8) DEFAULT_MESH_INDICES = range(54) GUI_PATH = str(os.path.join(RESOURCES_PATH, "gui.ma").replace("\\", "/")) ASSEMBLE_SCRIPT = str(os.path.join(RESOURCES_PATH, "additional_assemble_script.py").replace("\\", "/")) # SYSTEM_INFO SYSTEM_OS = str("Windows" if cmds.about(os=True).lower().startswith("win") else "Linux") MAYA_VERSION = str(int(cmds.about(version=True).split('.')[0])) # PYTHON_VERSION PYTHON_VERSION = str(sys.version.replace(".", "")) major_version = int(PYTHON_VERSION[0]) minor_version = int(PYTHON_VERSION[1:3]) if len(PYTHON_VERSION) > 1 else None version_tuple = (major_version,) if minor_version is None else (major_version, minor_version) # 版本映射表 PYTHON_VERSION_MAP = { (3,): "python3", # 所有Python3主版本 (3, 9): "python397", # 3.9.x → python397 (3, 10): "python3108", # 3.10.x → python3108 (3, 11): "python311" # 3.11.x → python311 } # 获取Python版本目录 PYTHON_VERSION_DIR = str(PYTHON_VERSION_MAP.get(version_tuple, "python3")) # PATHS PLUGIN_PATH = str(os.path.join(TOOL_PATH, "plugins", SYSTEM_OS, MAYA_VERSION).replace("\\", "/")) PYDNA_PATH = str(os.path.join(TOOL_PATH, "plugins", SYSTEM_OS, "pydna", PYTHON_VERSION_DIR).replace("\\", "/")) # TOOLS_PATH DNACALIB_PATH = str(os.path.join(TOOL_PATH, "dnacalib").replace("\\", "/")) 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("\\", "/")) # FILES TOOL_MAIN_SCRIPT = str(os.path.join(SCRIPTS_PATH, f"{TOOL_NAME}.py").replace("\\", "/")) TOOL_STYLE_FILE = str(os.path.join(UI_PATH, "style.qss").replace("\\", "/")) TOOL_ICON = str(os.path.join(ICONS_PATH, f"{TOOL_NAME}Logo.png").replace("\\", "/")) TOOL_COMMAND_ICON = str(os.path.join(ICONS_PATH, "CommandButton.png").replace("\\", "/")) TOOL_MOD_FILENAME = str(f"{TOOL_NAME}.mod") if __name__ == "__main__": validate_paths = { TOOL_PATH, SCRIPTS_PATH, ICONS_PATH, STYLES_PATH, DNA_FILE_PATH, DNA_IMG_PATH, PLUGIN_PATH, PYDNA_PATH, DNACALIB_PATH, BUILDER_PATH, DNALIB_PATH, UI_PATH, UTILS_PATH, GUI_PATH, ASSEMBLE_SCRIPT } for i in validate_paths: if not i in sys.path: sys.path.append(i) print("============================================") print(f"TOOL_NAME: {TOOL_NAME}") print(f"TOOL_VERSION: {TOOL_VERSION}") print(f"TOOL_AUTHOR: {TOOL_AUTHOR}") print(f"TOOL_LANG: {TOOL_LANG}") print(f"TOOL_WSCL_NAME: {TOOL_WSCL_NAME}") print(f"TOOL_HELP_URL: {TOOL_HELP_URL}") print(f"TOOL_PATH: {TOOL_PATH}") print(f"SCRIPTS_PATH: {SCRIPTS_PATH}") print(f"ICONS_PATH: {ICONS_PATH}") print(f"STYLES_PATH: {STYLES_PATH}") print(f"DNA_FILE_PATH: {DNA_FILE_PATH}") print(f"DNA_IMG_PATH: {DNA_IMG_PATH}") print(f"PLUGIN_PATH: {PLUGIN_PATH}") print(f"PYDNA_PATH: {PYDNA_PATH}") print(f"DNACALIB_PATH: {DNACALIB_PATH}") print(f"BUILDER_PATH: {BUILDER_PATH}") print(f"DNALIB_PATH: {DNALIB_PATH}") print(f"UI_PATH: {UI_PATH}") print(f"UTILS_PATH: {UTILS_PATH}") print(f"TOOL_MAIN_SCRIPT: {TOOL_MAIN_SCRIPT}") print(f"TOOL_STYLE_FILE: {TOOL_STYLE_FILE}") print(f"TOOL_ICON: {TOOL_ICON}") print(f"TOOL_COMMAND_ICON: {TOOL_COMMAND_ICON}") print(f"TOOL_MOD_FILENAME: {TOOL_MOD_FILENAME}")