Need to run a js script automatically from system commands (python subprocess)
Hi, I need a solution to open a specific project file and then execute a js script. This needs to be an automated process executed through python in Maya. The script is a list of instructions which updates a template project with shot and camera information which it reads from a json file. This script works correctly when run manually with the template project already open. But I need an automated process (client's request) to eliminate steps for artists.
I've tried the following without success:
os.system("path/projectFile.aep")
works on some computers and not others. When it works, it opens the correct project file but can't execute the script.
subprocess.run([app,"path/projectFile.aep" ])
will open the correct project file (though I have not tested it on other machines)
app = systemPath/AfterFX.exe
js_file = path/automationSript.js
subprocess.run([app, "path/projectFile.aep", "var a = new File("+js_file+" ;, a.open();, eval(a.read());])
opens after efffects to the correct project file but does not execute the js script.
subprocess.run([app,"var a = new File("+js_file+" ;, a.open();, eval(a.read());])
opens after efffects but fails when trying to execute the js script.
Caveats:
The correct project file needs to be opened first before the script executes. This is because the scipt uses the file path of the current project to locate the json file with all the necessary data, and the script updates pre-built comps, layers, sliders etc within that project file. This template is editable and customizable by client's supervisors and needs to maintain that flexibility, so the automation script can't build all that from scratch. It needs to be run after that project file is open in the application.
Please help.
thanks