#!/usr/bin/env python # -*- coding: utf-8 -*- import os import sys import json # Basic Information TOOL_NAME = "MetaWhiz" TOOL_VERSION = "Beta v1.0.0" TOOL_AUTHOR = "CGNICO" # Path Configuration TOOL_ROOT = os.path.dirname(os.path.abspath(__file__)).replace("\\", "/") SCRIPTS_PATH = os.path.join(TOOL_ROOT, "scripts").replace("\\", "/") ASSETS_PATH = os.path.join(TOOL_ROOT, "assets").replace("\\", "/") ICONS_PATH = os.path.join(TOOL_ROOT, "icons").replace("\\", "/") PLUGINS_PATH = os.path.join(TOOL_ROOT, "plugins").replace("\\", "/") STYLE_PATH = os.path.join(SCRIPTS_PATH, "style").replace("\\", "/") # DNA Related Configuration DNA_FILE_PATH = os.path.join(ASSETS_PATH, "dna").replace("\\", "/") DNA_IMG_PATH = os.path.join(ASSETS_PATH, "img").replace("\\", "/") DNA_VERSION = "MH.4" # Default using MetaHuman 4.0 version METAHUMAN_PATH = os.path.join(ASSETS_PATH, DNA_VERSION).replace("\\", "/") # DNA Calibration Path DNA_CALIB_PATH = os.path.join(TOOL_ROOT, "Reference", "MetaHuman-DNA-Calibration").replace("\\", "/") # System Information import maya.cmds as cmds SYSTEM_OS = "Windows" if cmds.about(os=True).lower().startswith("win") else "Linux" # Define Maya version as integer for easier version comparison MAYA_VERSION = int(cmds.about(version=True).split('.')[0]) # String version for paths MAYA_VERSION_STR = str(MAYA_VERSION) # Python Version PYTHON_VERSION = f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}" def get_python_version_dir(): """Get Python version directory name""" version = sys.version_info if version.major == 3: if version.minor == 9 and version.micro == 7: return "python397" elif version.minor == 10 and version.micro == 8: return "python3108" elif version.minor == 11: return "python311" return "python3" PYTHON_VERSION_DIR = get_python_version_dir() # Plugin Paths PLUGIN_OS_PATH = os.path.join(PLUGINS_PATH, SYSTEM_OS).replace("\\", "/") PLUGIN_MAYA_PATH = os.path.join(PLUGIN_OS_PATH, MAYA_VERSION_STR).replace("\\", "/") PYDNA_PATH = os.path.join(PLUGIN_OS_PATH, "pydna", PYTHON_VERSION_DIR).replace("\\", "/") # Load Configuration def load_json_config(file_path): """Load JSON configuration file""" if os.path.exists(file_path): try: with open(file_path, 'r', encoding='utf-8') as f: return json.load(f) except Exception as e: print(f"Failed to load configuration file: {file_path}, error: {str(e)}") return {} # Save Configuration def save_json_config(file_path, data): """Save JSON configuration file""" try: with open(file_path, 'w', encoding='utf-8') as f: json.dump(data, f, indent=4, ensure_ascii=False) return True except Exception as e: print(f"Failed to save configuration file: {file_path}, error: {str(e)}") return False # 初始化路径 def init_paths(): """Initialize paths""" paths = [ SCRIPTS_PATH, ASSETS_PATH, ICONS_PATH, PLUGINS_PATH, DNA_FILE_PATH, DNA_IMG_PATH, PLUGIN_OS_PATH, PLUGIN_MAYA_PATH, PYDNA_PATH, STYLE_PATH ] for path in paths: if not os.path.exists(path): try: os.makedirs(path) print(f"Created directory: {path}") except Exception as e: print(f"Failed to create directory: {path}, error: {str(e)}") if __name__ == "__main__": # Initialize paths init_paths() # Print configuration information print("=" * 50) print(f"TOOL_NAME: {TOOL_NAME}") print(f"TOOL_VERSION: {TOOL_VERSION}") print(f"TOOL_AUTHOR: {TOOL_AUTHOR}") print(f"TOOL_ROOT: {TOOL_ROOT}") print(f"SCRIPTS_PATH: {SCRIPTS_PATH}") print(f"SCRIPTS_PATH: {SCRIPTS_PATH}") print(f"ASSETS_PATH: {ASSETS_PATH}") print(f"ICONS_PATH: {ICONS_PATH}") print(f"PLUGINS_PATH: {PLUGINS_PATH}") print(f"DNA_FILE_PATH: {DNA_FILE_PATH}") print(f"DNA_IMG_PATH: {DNA_IMG_PATH}") print(f"DNA_VERSION: {DNA_VERSION}") print(f"METAHUMAN_PATH: {METAHUMAN_PATH}") print(f"SYSTEM_OS: {SYSTEM_OS}") print(f"MAYA_VERSION: {MAYA_VERSION}") print(f"PYTHON_VERSION: {PYTHON_VERSION}") print(f"PYTHON_VERSION_DIR: {PYTHON_VERSION_DIR}") print(f"PLUGIN_OS_PATH: {PLUGIN_OS_PATH}") print(f"PLUGIN_MAYA_PATH: {PLUGIN_MAYA_PATH}") print(f"PYDNA_PATH: {PYDNA_PATH}") print("=" * 50)