OmniJS canvas.background bug?

The OmniGraffle 7.3 (Test) OmniJS documentation lists Canvas.background as a property, but attempts to access it raise error messages suggesting that the background is a shape which “has been removed”.


Scripting access to the background is generally useful, not only for reading and setting graphic properties, but also for writing general meta info to canvas.background.notes.

(In my case, I am maintaining a JSON model of the structure of a hierarchical diagram, to allow for hierarchy-aware reformatting, and for some basic layouts not provided by the built-in Graphviz engine).

For reference, in JXA we can read and write to the canvas.background, including its notes property, in this pattern:

(() => {
    'use strict';

        og = Application("OmniGraffle"),
        ds = og.documents,
        d = ds.length > 0 ? : undefined;

    if (d) {
            cnvs = d.canvases,
            intCnv = cnvs.length,
            cnv = intCnv > 0 ? - 1) : undefined,
            shps = cnv ? cnv.shapes : [];

        cnv.canvasbackground.notes = "JSON\ntree model ...";
        return cnv.canvasbackground.notes();

PS, to pin down the version in which I am seeing this:

Thanks for finding this! It was an error in validating the object reference which should be fixed in revision 283675.

1 Like

Thank you ! That was quick !