@ -2,8 +2,8 @@ import os
import sys
from pymxs import runtime as rt
# Versão v1. 0.9 - Correção de Wrapper CUI
VERSION = " 1. 0.9 "
# 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 } " )
@ -22,57 +22,69 @@ def install_plugin():
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
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_Update category: " Immerse " buttonText: " Atualizar VR4Life " (on execute do python.ExecuteFile @ " { update_script } " ) ' )
# 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.
# 3. INJEÇÃO NO MENU RENDERING VIA MAXSCRIPT (Para evitar erro de Wrapper no Python)
log ( " Injetando itens no menu Rendering... " )
log ( " Injetando no menu Rendering de forma segura... " )
mxs_command = '''
safe_menu_script = '''
(
local cuiMgr = cui . getContentManager ( )
local mainMenuBar = cuiMgr . mainMenuBar
local renderMenu = undefined
- - Procura o menu Rendering
for i = 0 to mainMenuBar . numItems - 1 do (
local item = mainMenuBar . getItem i
if ( matchPattern item . displayText pattern : " *Rendering* " ) then (
renderMenu = item
exit
)
- - 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 render_menu != undefined then (
- - Adiciona os itens no final do menu Rendering
renderMenu . addActionItem " VR4Life_Open " " Immerse "
renderMenu . addActionItem " VR4Life_Update " " Immerse "
cuiMgr . updateMainMenuBar ( )
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 (
false
)
) else ( " Menu já existe. " )
) else ( false )
)
'''
success = rt . execute ( mxs_command )
if success :
log ( " Sucesso: Itens adicionados ao menu Rendering. " )
else :
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() ' )
menu_result = rt . execute ( safe_menu_script )
log ( f " Resultado da criação do menu: { menu_result } " )
# 4. EXECUÇÃO DA JANELA
# 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 \n Confira o final do menu Rendering ." , title = " VR4Life " )
rt . messageBox ( f " VR4Life v { VERSION } instalado! \n \n Se o menu não aparecer em ' Rendering ' , você pode adicionar manualmente em: Customize > Customize User Interface > Menus ." , title = " VR4Life " )
if __name__ == " __main__ " :
install_plugin ( )