eeee
parent
5fc5479ea4
commit
6633e2a6c8
@ -1,38 +1,48 @@
|
|||||||
import os
|
import os
|
||||||
from pymxs import runtime as rt
|
from pymxs import runtime as rt
|
||||||
|
|
||||||
def force_menu_load():
|
def force_menu_to_ui():
|
||||||
try:
|
try:
|
||||||
# 1. Caminho onde o arquivo foi copiado pelo script principal
|
# 1. Garante que o MacroScript (Action) existe para o botão funcionar
|
||||||
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")
|
|
||||||
|
|
||||||
if os.path.exists(caminho_mnx):
|
|
||||||
print(f"Carregando menu: {caminho_mnx}")
|
|
||||||
# Comando para carregar o arquivo de menu imediatamente
|
|
||||||
rt.menuMan.loadMenuFile(caminho_mnx)
|
|
||||||
rt.menuMan.updateMenuBar()
|
|
||||||
print("Menu VR4Life carregado com sucesso!")
|
|
||||||
else:
|
|
||||||
print("Arquivo .mnx ainda não encontrado no destino final.")
|
|
||||||
|
|
||||||
# 2. Registrar a Macro (para o botão saber o que executar)
|
|
||||||
plugin_dir = os.path.dirname(os.path.realpath(__file__)).replace("\\", "/")
|
plugin_dir = os.path.dirname(os.path.realpath(__file__)).replace("\\", "/")
|
||||||
macro_script = f"""
|
macro_cmd = f"""
|
||||||
macroScript VR4Life_Launcher
|
macroScript VR4Life_Launcher
|
||||||
category:"VR4Life"
|
category:"Immerse Games"
|
||||||
tooltip:"Abrir VR4Life"
|
tooltip:"Abrir VR4Life"
|
||||||
(
|
(
|
||||||
python.executeFile @{plugin_dir}/run_vr4life.py@
|
python.executeFile @{plugin_dir}/run_vr4life.py@
|
||||||
)
|
)
|
||||||
"""
|
"""
|
||||||
rt.execute(macro_script)
|
rt.execute(macro_cmd)
|
||||||
|
|
||||||
|
# 2. Localiza a barra de menus principal do 3ds Max
|
||||||
|
main_menu = rt.menuMan.getMainMenuBar()
|
||||||
|
|
||||||
|
# 3. Verifica se o menu VR4Life já está lá para não duplicar
|
||||||
|
already_exists = False
|
||||||
|
for i in range(1, main_menu.numItems() + 1):
|
||||||
|
if main_menu.getItem(i).getTitle() == "VR4Life":
|
||||||
|
already_exists = True
|
||||||
|
break
|
||||||
|
|
||||||
|
if not already_exists:
|
||||||
|
# Tenta encontrar o menu definido no seu .mnx
|
||||||
|
# No Max 2026, usamos o título que você deu no arquivo
|
||||||
|
vr_menu = rt.menuMan.findMenu("VR4Life")
|
||||||
|
|
||||||
|
if vr_menu:
|
||||||
|
# Cria o item de interface e insere antes do 'Help' (último item)
|
||||||
|
menu_item = rt.menuMan.createSubMenuItem("VR4Life", vr_menu)
|
||||||
|
main_menu.addItem(menu_item, main_menu.numItems())
|
||||||
|
rt.menuMan.updateMenuBar()
|
||||||
|
print("VR4Life: Menu injetado com sucesso na barra principal.")
|
||||||
|
else:
|
||||||
|
print("VR4Life: Definição de menu não encontrada. Tente reiniciar o Max.")
|
||||||
|
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Erro ao carregar menu: {str(e)}")
|
print(f"Erro ao injetar menu: {str(e)}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
force_menu_load()
|
force_menu_to_ui()
|
||||||
Loading…
Reference in New Issue