@ -2,12 +2,15 @@ import os
import sys
import sys
from pymxs import runtime as rt
from pymxs import runtime as rt
# Definição da Versão
VERSION = " 1.0.5 "
def log ( msg ) :
def log ( msg ) :
print ( f " [VR4Life Install Log] { msg } " )
print ( f " [VR4Life Install Log] { msg } " )
def install_plugin ( ) :
def install_plugin ( ) :
rt . clearListener ( )
rt . clearListener ( )
log ( " === FORÇANDO ATUALIZAÇÃO DE MENU (VR4Life) ===" )
log ( f" === INICIANDO INSTALAÇÃO VR4Life v { VERSION } ===" )
# 1. Configuração de Caminhos
# 1. Configuração de Caminhos
user_scripts_dir = rt . getDir ( rt . name ( " userScripts " ) )
user_scripts_dir = rt . getDir ( rt . name ( " userScripts " ) )
@ -22,7 +25,7 @@ def install_plugin():
product_name = " VR4Life "
product_name = " VR4Life "
category = " Immerse Games "
category = " Immerse Games "
# 2. Registro das Macros (Garante que os comandos existam)
# 2. Registro das Macros
rt . execute ( f '''
rt . execute ( f '''
macroScript VR4Life_Open category : " {category} " buttonText : " VR4Life Engine "
macroScript VR4Life_Open category : " {category} " buttonText : " VR4Life Engine "
( on execute do ( python . ExecuteFile @ " {run_script} " ) )
( on execute do ( python . ExecuteFile @ " {run_script} " ) )
@ -35,31 +38,30 @@ def install_plugin():
# 3. Lógica para 3ds Max 2025/2026 (CUI)
# 3. Lógica para 3ds Max 2025/2026 (CUI)
try :
try :
log ( " Acessando CUI Content Manager ..." )
log ( " Tentando injetar menu no sistema CUI ..." )
cui_mgr = rt . cui . getContentManager ( )
cui_mgr = rt . cui . getContentManager ( )
main_menu_bar = cui_mgr . mainMenuBar
main_menu_bar = cui_mgr . mainMenuBar
# REMOÇÃO AGRESSIVA: Procura por qualquer variação do nome para limpa r
# Limpa qualquer rastro anterio r
for i in range ( main_menu_bar . numItems - 1 , - 1 , - 1 ) :
for i in range ( main_menu_bar . numItems - 1 , - 1 , - 1 ) :
item = main_menu_bar . getItem ( i )
item = main_menu_bar . getItem ( i )
if item . displayText in [ product_name , " 1-VR4Life " , " vr4life " ]:
if item . displayText in [ product_name , " 1-VR4Life " ]:
main_menu_bar . removeItem ( item )
main_menu_bar . removeItem ( item )
log ( f " Limpando resquício: { item . displayText } " )
# C RIAÇÃO DO MENU
# C riação do Menu
new_menu = cui_mgr . createCustomMenu ( product_name )
new_menu = cui_mgr . createCustomMenu ( product_name )
new_menu . addActionItem ( " VR4Life_Open " , category )
new_menu . addActionItem ( " VR4Life_Open " , category )
new_menu . addActionItem ( " VR4Life_Update " , category )
new_menu . addActionItem ( " VR4Life_Update " , category )
# Adiciona ao final (-1)
# -1 coloca no final da lista
main_menu_bar . addItem ( new_menu , - 1 )
main_menu_bar . addItem ( new_menu , - 1 )
# REFRESH TOTAL: Força o Max a reescrever o arquivo de menu no disco
# FORÇAR REFRESH E SALVAMENTO (Crucial para o 2026)
rt. execute ( " cui.getContentManager().updateMainMenuBar() " )
cui_mgr. updateMainMenuBar ( )
log ( " Menu injetado e interface atualizada." )
log ( " Interface CUI atualizada." )
except AttributeError :
except AttributeError :
# Lógica Legada (2024 e anteriores )
# Lógica Legada (2024 )
if hasattr ( rt , " menuMan " ) :
if hasattr ( rt , " menuMan " ) :
main_menu = rt . menuMan . getMainMenuBar ( )
main_menu = rt . menuMan . getMainMenuBar ( )
existing = rt . menuMan . findMenu ( product_name )
existing = rt . menuMan . findMenu ( product_name )
@ -70,13 +72,18 @@ def install_plugin():
sub_item = rt . menuMan . createSubMenuItem ( product_name , new_menu )
sub_item = rt . menuMan . createSubMenuItem ( product_name , new_menu )
main_menu . addItem ( sub_item , - 1 )
main_menu . addItem ( sub_item , - 1 )
rt . menuMan . updateMenuBar ( )
rt . menuMan . updateMenuBar ( )
log ( " Interface Legacy atualizada. " )
# 4. EXECUTAR A JANELA
# 4. EXECUTAR A JANELA
if os . path . exists ( run_script ) :
if os . path . exists ( run_script ) :
log ( " Abrindo janela do plugin ..." )
log ( f" Abrindo interface v { VERSION } ..." )
rt . python . ExecuteFile ( run_script )
rt . python . ExecuteFile ( run_script )
log ( " === INSTALAÇÃO CONCLUÍDA === " )
log ( f " === INSTALAÇÃO CONCLUÍDA v { VERSION } === " )
# Mensagem final com versão para o usuário
msg = f " VR4Life v { VERSION } instalado com sucesso! \n \n O menu deve aparecer ao final da lista superior. \n Caso não veja, reinicie o 3ds Max ou troque o Workspace. "
rt . messageBox ( msg , title = f " VR4Life v { VERSION } " )
if __name__ == " __main__ " :
if __name__ == " __main__ " :
install_plugin ( )
install_plugin ( )