Skip to main content
 首页 » 编程设计

python之将 python 脚本的结果传递给 ExtendScript `.jsx` 文件

2024年10月01日6qq号

因此,我正在编写一个 python 脚本,该脚本从 google 工作表获取数据并将其返回到我为 After Effects 编写的 ExtendScript 脚本。

相关位是:

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!"); 

所以,我有三个问题:

  1. 如何将变量从 afterEffectsScript.jsx 传递到 python 脚本(例如电子表格 ID 和范围)?

  2. 如何从 python 脚本获取返回并将其返回到 jsx 文件?

  3. 如何让我的 afterEffectsScript 异步工作,以便它可以等待 python 脚本获得它需要的东西...

提前感谢您的建议!

-P

请您参考如下方法:

After Effects 可以调用系统命令并获取 stdout 的结果。

var cmd = "pwd"; 
var stdout = system.callSystem(cmd); 
$.writeln(stdout); 

查看 AE Scripting Guide