You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
2.0 KiB
Python

import os
from pymxs import runtime as rt
def carregar_menu_mnx():
rt.clearListener()
print("\n" + "="*50)
print("LOG DE INSTALAÇÃO DE INTERFACE - VR4LIFE")
print("="*50)
try:
# 1. Definir caminhos
pasta_macros = rt.pathConfig.getDir(rt.name("userMacros"))
pasta_enu = os.path.dirname(pasta_macros)
caminho_mnx = os.path.join(pasta_enu, "en-US", "UI", "vr4life.mnx").replace("\\", "/")
plugin_dir = os.path.dirname(os.path.realpath(__file__)).replace("\\", "/")
run_script = f"{plugin_dir}/run_vr4life.py"
print(f"[*] Pasta do Plugin: {plugin_dir}")
print(f"[*] Caminho do MNX: {caminho_mnx}")
# 2. Registrar MacroScript
print("[*] Registrando MacroScript VR4Life_Launcher...")
macro_cmd = f'macroScript VR4Life_Launcher category:"Immerse Games" tooltip:"Abrir VR4Life" (on execute do python.executeFile "{run_script}")'
rt.execute(macro_cmd)
# 3. Carregar MNX
if os.path.exists(caminho_mnx):
print(f"[!] Arquivo MNX encontrado. Solicitando carregamento ao 3ds Max...")
# Comando com verificação interna do MaxScript
cmd_load = f"""
(
if menuMan != undefined then (
local result = menuMan.loadMenuFile @{caminho_mnx}@
menuMan.updateMenuBar()
format ">> MaxScript: loadMenuFile result: %\\n" result
) else (
format ">> MaxScript Erro: menuMan ainda e undefined\\n"
)
)
"""
rt.execute(cmd_load)
else:
print(f"[X] ERRO: Arquivo {caminho_mnx} NAO existe no disco.")
print("="*50)
print("FIM DO LOG DE INSTALAÇÃO")
print("="*50 + "\n")
except Exception as e:
print(f"\n[EXCEPTION] Ocorreu uma falha grave:\n{str(e)}")
if __name__ == "__main__":
carregar_menu_mnx()