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”.

Context

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';

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

    if (d) {
        const
            cnvs = d.canvases,
            intCnv = cnvs.length,
            cnv = intCnv > 0 ? cnvs.at(intCnv - 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:

177.3.0.283059

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 !