main
parent
fba61ac174
commit
c81edc3a12
@ -1,77 +1,51 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import shutil
|
||||||
from pymxs import runtime as rt
|
import pymxs
|
||||||
|
|
||||||
VERSION = "1.1.2"
|
def instalar_menu_vr4life():
|
||||||
|
try:
|
||||||
def log(msg):
|
# 1. Pega o nome exato do arquivo que você gerou no 3ds Max
|
||||||
print(f"[VR4Life Install Log] {msg}")
|
# (Altere aqui se você salvou com outro nome)
|
||||||
|
nome_arquivo_mnx = "VR4Life.mnx"
|
||||||
def install_plugin():
|
|
||||||
rt.clearListener()
|
|
||||||
log(f"=== INSTALAÇÃO TOOLBAR 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
|
|
||||||
log("Registrando Macros...")
|
|
||||||
mxs_macros = f'''
|
|
||||||
(
|
|
||||||
macroScript VR4Life_Open category:"VR4Life" buttonText:"Engine" tooltip:"Abrir VR4Life Engine" (on execute do python.ExecuteFile @"{run_script}")
|
|
||||||
macroScript VR4Life_Update category:"VR4Life" buttonText:"Update" tooltip:"Atualizar Plugin" (on execute do python.ExecuteFile @"{update_script}")
|
|
||||||
)
|
|
||||||
'''
|
|
||||||
rt.execute(mxs_macros)
|
|
||||||
|
|
||||||
# 3. CRIAÇÃO DA TOOLBAR (Barra de Ferramentas)
|
|
||||||
log("Criando Barra de Ferramentas...")
|
|
||||||
|
|
||||||
toolbar_script = '''
|
|
||||||
(
|
|
||||||
local tbName = "VR4Life_Toolbar"
|
|
||||||
|
|
||||||
-- Se a barra já existir, ela será atualizada
|
# 2. Descobre a pasta atual onde este instalador Python está rodando
|
||||||
if (cui.getToolbarVisibility tbName) then (
|
diretorio_atual = os.path.dirname(os.path.realpath(__file__))
|
||||||
cui.showToolbar tbName false
|
caminho_origem_mnx = os.path.join(diretorio_atual, nome_arquivo_mnx)
|
||||||
)
|
|
||||||
|
# Trava de segurança: verifica se você não esqueceu de colocar o .mnx junto
|
||||||
|
if not os.path.exists(caminho_origem_mnx):
|
||||||
|
pymxs.runtime.messageBox(
|
||||||
|
f"Erro na instalação: O arquivo '{nome_arquivo_mnx}' não foi encontrado na pasta.",
|
||||||
|
title="VR4Life - Erro"
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
|
||||||
|
# 3. Magia do pymxs: Pergunta ao 3ds Max onde fica a pasta UI daquele usuário
|
||||||
|
# Geralmente é C:\Users\[Nome]\AppData\Local\Autodesk\3dsMax\2026 - 64bit\ENU\en-US\UI\
|
||||||
|
pasta_ui_usuario = pymxs.runtime.pathConfig.getDir(pymxs.runtime.name("userUI"))
|
||||||
|
caminho_destino_mnx = os.path.join(pasta_ui_usuario, nome_arquivo_mnx)
|
||||||
|
|
||||||
|
# 4. Copia o arquivo .mnx silenciosamente para a máquina do cliente
|
||||||
|
shutil.copy2(caminho_origem_mnx, caminho_destino_mnx)
|
||||||
|
|
||||||
-- Cria a toolbar via CUI (Método compatível com 2026)
|
# 5. Avisa no console interno do 3ds Max que deu certo (ótimo para debug)
|
||||||
try (
|
pymxs.runtime.print_(f"VR4Life: Arquivo de menu copiado com sucesso para {pasta_ui_usuario}\n")
|
||||||
cui.createToolbar tbName
|
|
||||||
cui.addMacroButton tbName "VR4Life" "VR4Life_Open"
|
|
||||||
cui.addMacroButton tbName "VR4Life" "VR4Life_Update"
|
|
||||||
cui.showToolbar tbName true
|
|
||||||
"Toolbar Criada"
|
|
||||||
) catch (
|
|
||||||
"Erro ao criar Toolbar automaticamente"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
'''
|
|
||||||
|
|
||||||
tb_result = rt.execute(toolbar_script)
|
|
||||||
log(f"Resultado: {tb_result}")
|
|
||||||
|
|
||||||
# 4. EXECUÇÃO DA JANELA
|
# 6. Alerta final de sucesso na tela para a sua equipe
|
||||||
if os.path.exists(run_script):
|
pymxs.runtime.messageBox(
|
||||||
rt.python.ExecuteFile(run_script)
|
"O menu do VR4Life foi instalado com sucesso!\n\nSe ele não aparecer imediatamente no topo, reinicie o 3ds Max.",
|
||||||
|
title="VR4Life - Instalação Concluída"
|
||||||
|
)
|
||||||
|
return True
|
||||||
|
|
||||||
log(f"=== FINALIZADO v{VERSION} ===")
|
except Exception as e:
|
||||||
|
# Captura qualquer erro (falta de permissão no Windows, etc.)
|
||||||
msg = f"VR4Life v{VERSION} Instalado!\n\n"
|
pymxs.runtime.messageBox(
|
||||||
if tb_result == "Toolbar Criada":
|
f"Falha ao instalar o menu.\nErro técnico: {str(e)}",
|
||||||
msg += "Uma barra de ferramentas flutuante apareceu na tela.\nVocê pode acoplá-la onde preferir."
|
title="VR4Life - Erro Fatal"
|
||||||
else:
|
)
|
||||||
msg += "Não foi possível criar a barra automaticamente.\nAdicione manualmente: Botão direito na barra de menus > VR4Life."
|
return False
|
||||||
|
|
||||||
rt.messageBox(msg, title="VR4Life")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
# Dispara a função quando o script for rodado no 3ds Max
|
||||||
install_plugin()
|
if __name__ == '__main__':
|
||||||
|
instalar_menu_vr4life()
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<MaxMenuTransformations>
|
||||||
|
<CreateTopLevelMenu Id="167d260c-f391-4e63-b6a9-4798fbfcadc5" Title="Vr4Life"/>
|
||||||
|
<CreateMenuAction MenuId="167d260c-f391-4e63-b6a9-4798fbfcadc5" Id="a37d867e-3d05-4859-9a55-70cd394c8e72" ActionId="647394-VR4Life_Launcher`Immerse Games"/>
|
||||||
|
<CreateMenuAction MenuId="167d260c-f391-4e63-b6a9-4798fbfcadc5" Id="8df661bf-5425-4fbf-9ee3-ac14cd067b0c" ActionId="647394-VR4Life_Launcher`Immerse Games"/>
|
||||||
|
<DeleteItem Id="8df661bf-5425-4fbf-9ee3-ac14cd067b0c"/>
|
||||||
|
<DeleteItem Id="a37d867e-3d05-4859-9a55-70cd394c8e72"/>
|
||||||
|
<CreateMenuAction MenuId="167d260c-f391-4e63-b6a9-4798fbfcadc5" Id="d66e56ef-ecf4-4758-923e-b7ce929e440c" ActionId="647394-VR4Life_Launcher`Immerse Games"/>
|
||||||
|
<CreateMenuAction MenuId="167d260c-f391-4e63-b6a9-4798fbfcadc5" Id="071a64d3-3fe9-4674-b58a-b5e3047e3109" ActionId="647394-VR4Life_Update`Immerse Games"/>
|
||||||
|
</MaxMenuTransformations>
|
||||||
Loading…
Reference in New Issue