我不知道如何将以下 AppleScript 转换为 JXA(Mac OS X Yosemite 下的自动化 JavaScript):
tell application id "com.omnigroup.OmniGraffle6"
tell canvas of front window
make new line at end of graphics with properties {point list:L, draws shadow:false}
end tell
end tell
这是我尝试过的方法,但在执行最后一行时失败,并出现错误“AppleEvent handler failed”:
app = Application('OmniGraffle')
pt1 = app.Point({x:1,y:2})
pt2 = app.Point({x:1,y:2})
L = []
L.push(pt1)
L.push(pt2)
line = app.Line({pointList:L})
app.documents[0].canvases[0].lines.push(line)
有人可以帮忙吗?
谢谢, 奥雷利安
最佳答案
图形对象(线条、形状等)包含在图形集合中。因此,您必须将最后一行更改为
app.documents[0].canvases[0].graphics.push(line)
关于javascript - JXA 和 OmniGraffle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29327338/