henrique 2 months ago
parent 142c2a6b48
commit f5a7f3172c

@ -2,14 +2,15 @@ import os
import sys import sys
from pymxs import runtime as rt from pymxs import runtime as rt
# Versão de Teste Direto # Versão v1.0.9 - Correção de Wrapper CUI
VERSION = "1.0.8-DEBUG" VERSION = "1.0.9"
def log(msg):
print(f"[VR4Life Install Log] {msg}")
def install_plugin(): def install_plugin():
# Limpa o console para você ler com clareza
rt.clearListener() rt.clearListener()
log(f"=== INICIANDO INSTALAÇÃO v{VERSION} ===")
print(f"--- DEBUG INICIADO v{VERSION} ---")
# 1. SETUP DE PASTAS # 1. SETUP DE PASTAS
user_scripts_dir = rt.getDir(rt.name("userScripts")) user_scripts_dir = rt.getDir(rt.name("userScripts"))
@ -21,47 +22,57 @@ def install_plugin():
run_script = os.path.join(plugin_dir, "run_vr4life.py").replace("\\", "/") run_script = os.path.join(plugin_dir, "run_vr4life.py").replace("\\", "/")
update_script = os.path.join(plugin_dir, "vr4life_updater.py").replace("\\", "/") update_script = os.path.join(plugin_dir, "vr4life_updater.py").replace("\\", "/")
print(f"Pasta do Plugin: {plugin_dir}")
# 2. REGISTRO DE MACROS # 2. REGISTRO DE MACROS
print("Registrando Macros...") log("Registrando Macros...")
rt.execute(f'macroScript VR4Life_Open category:"Immerse" buttonText:"VR4Life Engine" (on execute do python.ExecuteFile @"{run_script}")') rt.execute(f'macroScript VR4Life_Open category:"Immerse" buttonText:"VR4Life Engine" (on execute do python.ExecuteFile @"{run_script}")')
rt.execute(f'macroScript VR4Life_Update category:"Immerse" buttonText:"Atualizar VR4Life" (on execute do python.ExecuteFile @"{update_script}")') rt.execute(f'macroScript VR4Life_Update category:"Immerse" buttonText:"Atualizar VR4Life" (on execute do python.ExecuteFile @"{update_script}")')
# 3. TENTATIVA DE INJEÇÃO NO MENU RENDERING (SEM SUPRESSÃO DE ERRO) # 3. INJEÇÃO NO MENU RENDERING VIA MAXSCRIPT (Para evitar erro de Wrapper no Python)
print("Localizando CUI Content Manager...") log("Injetando itens no menu Rendering...")
cui_mgr = rt.cui.getContentManager()
main_menu_bar = cui_mgr.mainMenuBar mxs_command = '''
(
render_menu = None local cuiMgr = cui.getContentManager()
# No Max 2026 o nome pode variar entre "Rendering" e "&Rendering" local mainMenuBar = cuiMgr.mainMenuBar
for i in range(main_menu_bar.numItems): local renderMenu = undefined
item = main_menu_bar.getItem(i)
if "Rendering" in item.displayText: -- Procura o menu Rendering
render_menu = item for i = 0 to mainMenuBar.numItems - 1 do (
print(f"Menu Rendering encontrado no índice: {i}") local item = mainMenuBar.getItem i
break if (matchPattern item.displayText pattern:"*Rendering*") then (
renderMenu = item
if render_menu: exit
print("Adicionando itens ao menu Rendering...") )
# Adiciona separador e itens )
render_menu.addActionItem("VR4Life_Open", "Immerse")
render_menu.addActionItem("VR4Life_Update", "Immerse") if render_menu != undefined then (
-- Adiciona os itens no final do menu Rendering
print("Forçando atualização da barra de menus...") renderMenu.addActionItem "VR4Life_Open" "Immerse"
cui_mgr.updateMainMenuBar() renderMenu.addActionItem "VR4Life_Update" "Immerse"
cuiMgr.updateMainMenuBar()
true
) else (
false
)
)
'''
success = rt.execute(mxs_command)
if success:
log("Sucesso: Itens adicionados ao menu Rendering.")
else: else:
print("ERRO: Não foi possível localizar o menu Rendering na barra principal!") log("ERRO: Menu Rendering não encontrado. Criando menu no final da barra...")
# Fallback: Cria menu novo se o Rendering falhar
rt.execute('local m = (cui.getContentManager()).createCustomMenu "VR4Life"; m.addActionItem "VR4Life_Open" "Immerse"; m.addActionItem "VR4Life_Update" "Immerse"; (cui.getContentManager()).mainMenuBar.addItem m -1; (cui.getContentManager()).updateMainMenuBar()')
# 4. EXECUÇÃO DA JANELA # 4. EXECUÇÃO DA JANELA
if os.path.exists(run_script): if os.path.exists(run_script):
print("Executando janela principal...") log(f"Abrindo v{VERSION}...")
rt.python.ExecuteFile(run_script) rt.python.ExecuteFile(run_script)
else:
print(f"ERRO: Arquivo {run_script} não encontrado!")
print(f"--- DEBUG FINALIZADO v{VERSION} ---") log(f"=== INSTALAÇÃO FINALIZADA v{VERSION} ===")
rt.messageBox(f"Instalação v{VERSION} finalizada.\nCheque o log (F11) para ver se houve erros no console.", title="VR4Life Debug") rt.messageBox(f"VR4Life v{VERSION} instalado!\n\nConfira o final do menu Rendering.", title="VR4Life")
if __name__ == "__main__": if __name__ == "__main__":
install_plugin() install_plugin()
Loading…
Cancel
Save