import os import sys from pymxs import runtime as rt # Versão v1.1.0 - Correção Definitiva para o 3ds Max 2026 VERSION = "1.1.0" def log(msg): print(f"[VR4Life Install Log] {msg}") def install_plugin(): rt.clearListener() log(f"=== INICIANDO INSTALAÇÃO v{VERSION} ===") # 1. SETUP DE PASTAS user_scripts_dir = rt.getDir(rt.name("userScripts")) plugin_dir = os.path.join(user_scripts_dir, "VR4Life_Plugin").replace("\\", "/") if plugin_dir not in sys.path: sys.path.insert(0, plugin_dir) run_script = os.path.join(plugin_dir, "run_vr4life.py").replace("\\", "/") update_script = os.path.join(plugin_dir, "vr4life_updater.py").replace("\\", "/") # 2. REGISTRO DE MACROS (Comandos que o Max entende) log("Registrando Comandos VR4Life...") # Criamos a categoria 'Immerse Games' que aparecerá no Customize User Interface mxs_macro = f''' ( macroScript VR4Life_Open category:"Immerse Games" buttonText:"VR4Life Engine" ( on execute do python.ExecuteFile @"{run_script}" ) macroScript VR4Life_Update category:"Immerse Games" buttonText:"Atualizar VR4Life" ( on execute do python.ExecuteFile @"{update_script}" ) ) ''' rt.execute(mxs_macro) # 3. CRIAÇÃO DO MENU (Método Seguro para o 2026) # Como o getContentManager está falhando, vamos usar o menuMan de forma condicional # e injetar no menu 'Rendering' apenas se as funções básicas existirem. log("Injetando no menu Rendering de forma segura...") safe_menu_script = ''' ( -- Tenta o método clássico de MenuManager que ainda funciona para submenus local mainMenuBar = menuMan.getMainMenuBar() local renderMenuIdx = menuMan.findMenu "&Rendering" if renderMenuIdx != -1 then ( local renderMenu = menuMan.getMenu renderMenuIdx -- Verifica se já existe um item chamado VR4Life para não duplicar local exists = false for i = 1 to renderMenu.numItems() do ( local item = renderMenu.getItem i if item != undefined and (matchPattern (item.getTitle()) pattern:"*VR4Life*") then exists = true ) if not exists then ( local sep = menuMan.createSeparatorItem() renderMenu.addItem sep -1 local openItem = menuMan.createActionItem "VR4Life_Open" "Immerse Games" renderMenu.addItem openItem -1 local updateItem = menuMan.createActionItem "VR4Life_Update" "Immerse Games" renderMenu.addItem updateItem -1 menuMan.updateMenuBar() true ) else ( "Menu já existe." ) ) else ( false ) ) ''' menu_result = rt.execute(safe_menu_script) log(f"Resultado da criação do menu: {menu_result}") # 4. EXECUÇÃO DA JANELA (O que você já confirmou que funciona) if os.path.exists(run_script): log(f"Abrindo v{VERSION}...") rt.python.ExecuteFile(run_script) log(f"=== INSTALAÇÃO FINALIZADA v{VERSION} ===") rt.messageBox(f"VR4Life v{VERSION} instalado!\n\nSe o menu não aparecer em 'Rendering', você pode adicionar manualmente em: Customize > Customize User Interface > Menus.", title="VR4Life") if __name__ == "__main__": install_plugin()