From c81edc3a12907d48100291f1f35c906a1303aa1c Mon Sep 17 00:00:00 2001 From: henrique Date: Mon, 23 Feb 2026 20:56:47 -0300 Subject: [PATCH] ss --- install_vr4life.py | 116 ++++++++++++++++++--------------------------- vr4life.mnx | 10 ++++ 2 files changed, 55 insertions(+), 71 deletions(-) create mode 100644 vr4life.mnx diff --git a/install_vr4life.py b/install_vr4life.py index 6eaa747..3be155e 100644 --- a/install_vr4life.py +++ b/install_vr4life.py @@ -1,77 +1,51 @@ import os -import sys -from pymxs import runtime as rt - -VERSION = "1.1.2" - -def log(msg): - print(f"[VR4Life Install Log] {msg}") - -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" +import shutil +import pymxs + +def instalar_menu_vr4life(): + try: + # 1. Pega o nome exato do arquivo que você gerou no 3ds Max + # (Altere aqui se você salvou com outro nome) + nome_arquivo_mnx = "VR4Life.mnx" - -- Se a barra já existir, ela será atualizada - if (cui.getToolbarVisibility tbName) then ( - cui.showToolbar tbName false - ) + # 2. Descobre a pasta atual onde este instalador Python está rodando + diretorio_atual = os.path.dirname(os.path.realpath(__file__)) + 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) - try ( - 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}") + # 5. Avisa no console interno do 3ds Max que deu certo (ótimo para debug) + pymxs.runtime.print_(f"VR4Life: Arquivo de menu copiado com sucesso para {pasta_ui_usuario}\n") - # 4. EXECUÇÃO DA JANELA - if os.path.exists(run_script): - rt.python.ExecuteFile(run_script) + # 6. Alerta final de sucesso na tela para a sua equipe + pymxs.runtime.messageBox( + "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} ===") - - msg = f"VR4Life v{VERSION} Instalado!\n\n" - if tb_result == "Toolbar Criada": - msg += "Uma barra de ferramentas flutuante apareceu na tela.\nVocê pode acoplá-la onde preferir." - else: - msg += "Não foi possível criar a barra automaticamente.\nAdicione manualmente: Botão direito na barra de menus > VR4Life." - - rt.messageBox(msg, title="VR4Life") + except Exception as e: + # Captura qualquer erro (falta de permissão no Windows, etc.) + pymxs.runtime.messageBox( + f"Falha ao instalar o menu.\nErro técnico: {str(e)}", + title="VR4Life - Erro Fatal" + ) + return False -if __name__ == "__main__": - install_plugin() \ No newline at end of file +# Dispara a função quando o script for rodado no 3ds Max +if __name__ == '__main__': + instalar_menu_vr4life() \ No newline at end of file diff --git a/vr4life.mnx b/vr4life.mnx new file mode 100644 index 0000000..98bb037 --- /dev/null +++ b/vr4life.mnx @@ -0,0 +1,10 @@ + + + + + + + + + +