Return 来自 Python 的变量从 Photoshop 发送
Return variable from Python sent from Photoshop
我可以将变量(例如文档名称)从 Photoshop 传递到 Python 脚本(尽管是通过批处理文件)
Photoshop 脚本 hello_world.jsx
var srcDoc = app.activeDocument;
var batPath = "C:\temp\hello_world.bat";
$.setenv("DOC_NAME", docName);
File(batPath).execute();
hello_world.bat
@echo off
python D:\LearnPython\hello_world_photoshop.py %DOC_NAME%
pause 100
hello_world_photoshop.py
import sys
args = sys.argv[1:]
docName = " ".join(args)
results = "Photoshop document: " + docName
print (results)
# return results
如何将变量传回 Photoshop - 例如结果?
是的,我意识到这个获取文档名称和 运行 到 Python 然后再返回的例子有点多余。
将 hello_world_photoshop.py 的结果写入文件并在 photoshop 脚本中读取。
我真的不知道File(batPath).execute();
是否等待执行结束。如果是这样,那么您可以在该行之后读取生成的文件。如果它不等待,那么您可以将 javascript 的执行置于无限循环的暂停并检查结果文件更新。
我可以将变量(例如文档名称)从 Photoshop 传递到 Python 脚本(尽管是通过批处理文件)
Photoshop 脚本 hello_world.jsx
var srcDoc = app.activeDocument;
var batPath = "C:\temp\hello_world.bat";
$.setenv("DOC_NAME", docName);
File(batPath).execute();
hello_world.bat
@echo off
python D:\LearnPython\hello_world_photoshop.py %DOC_NAME%
pause 100
hello_world_photoshop.py
import sys
args = sys.argv[1:]
docName = " ".join(args)
results = "Photoshop document: " + docName
print (results)
# return results
如何将变量传回 Photoshop - 例如结果?
是的,我意识到这个获取文档名称和 运行 到 Python 然后再返回的例子有点多余。
将 hello_world_photoshop.py 的结果写入文件并在 photoshop 脚本中读取。
我真的不知道File(batPath).execute();
是否等待执行结束。如果是这样,那么您可以在该行之后读取生成的文件。如果它不等待,那么您可以将 javascript 的执行置于无限循环的暂停并检查结果文件更新。