0

次の 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)

誰でも助けることができますか?

ありがとう、オーレリアン

4

2 に答える 2

1

グラフィック オブジェクト (線、形状など) は、グラフィック コレクションに含まれています。したがって、最後の行を次のように変更する必要があります

app.documents[0].canvases[0].graphics.push(line)
于 2015-10-06T14:56:04.210 に答える
0

同等ですが、少し充実した例:

(function () {
    'use strict';

    var og = Application("OmniGraffle"),
        ds = og.documents,
        d = ds.length ? ds[0] : null,
        cnvs = d ? d.canvases : [],
        cnv = cnvs.length ? cnvs[0] : null,
        gs = cnv ? cnv.graphics : null;

    return gs ? (
        gs.push(
            og.Line({
                pointList: [[72, 216], [216, 72]],
                drawsShadow: true,
                thickness: 3,
                lineType: 'orthogonal',
                strokeColor: [1.0, 0.0, 0.0],
                headType: "FilledArrow"
            })
        )
    ) : null;

})();
于 2015-12-28T17:10:01.283 に答える