问题
So, I'm writing a python script that gets data from a google sheet and returns it back to an ExtendScript script that I'm writing for After Effects.
The relevant bits are :
getSpreadsheetData.py
def main():
values = getSpreadsheetRange("1M337m3YHCdCDcVyS4fITvAGJsw7rGQ2XGbZaKIdkJPc", "A1:Q41")
return processValues(values)
afterEffectsScript.jsx
var script_file = File("getSpreadsheetData.py");
var results = script_file.execute();
$.writeln(results);
alert("done!");
So, I have three questions :
How do I pass variables from the
afterEffectsScript.jsxto the python script (for example the spreadsheet id and range)?How do I get a return from the python script and return it back to the
jsxfile?How do I make my
afterEffectsScriptto work async so that it can wait for the python script to get what it needs...
Thanks in advance for the advice!
-P
回答1:
After Effects has the possibility to call system commands and get the result of stdout.
var cmd = "pwd";
var stdout = system.callSystem(cmd);
$.writeln(stdout);
Take a look into the AE Scripting Guide
回答2:
You can pass variables via setting environment variables. Small example how call external script with args from extendscript:
var script_file = File("getSpreadsheetData.py");
$.setenv("arg_1", "arg1_value");
$.setenv("arg_2", "arg2_value");
script_file.execute();
You python script should start with reading this varibles from environment: Access environment variables from Python
来源:https://stackoverflow.com/questions/42863672/passing-the-result-of-a-python-script-to-an-extendscript-jsx-file