我正在尝试Apple Script
为Sketch.app (com.bohemiancoding.sketch3)
编写一个。我想要做的是,创建一些可以从 Sketch 文档在浏览器中呈现的图像文件。
当我打开Sketch.app字典时,Script Editior
我看到
saveable file format enum
Sketch : The native Sketch 2 file format
PDF : Portable Document Format
TIFF : Tagged Image File Format
所以我考虑TIFF
使用以下脚本生成,但它不起作用
tell application "Sketch"
set curdoc to document 0
save curdoc in "/Users/mirza/Downloads/mew2" as TIFF
end tell
我可以使用保存命令创建草图副本,.sketch
但不能使用 PDF 或 TIFF。草图是否支持使用苹果脚本的 PDF 和 TIFF?
或者有没有其他方法可以解决这个问题。
更新
我将路径更改为苹果脚本格式并将文档索引设置为 1。现在脚本看起来像这样
set thisFilePath to (POSIX file "/Users/mirza/Downloads/mew2")
log thisFilePath
tell application "Sketch"
curdoc to document 1
save curdoc in thisFilePath as TIFF -- Tried with quotes as well, gives same error
end tell
但是当我运行脚本时出现以下错误
Result:
error "Sketch got an error: Can’t continue curdoc." number -1708
更新 2
修正错字
set thisFilePath to (POSIX file "/Users/mirza/Downloads/mew2")
log thisFilePath
tell application "Sketch"
set curdoc to document 1
log (path of curdoc)
save curdoc in thisFilePath as "TIFF"
end tell
但是当我运行脚本时出现以下错误
Result:
error "Sketch got an error: The document cannot be exported to the \"TIFF\" format." number -50