Changing Canvas by script


Is there a way to switch canvas by script - either AppleScript or JavaScript?


Yes! While I believe it is possible in AppleScript as well, for JavaScript we have a Canvas Tools plug-in that may suit your needs.

See for more information on using Canvases in JavaScript.


Thanks for the swift reply! However looking at the list of functions, I can’t see how I’d do this? I can see functions that change the order of canvases, and a function to get the current canvas - but how do I set the current canvas, that is get OG to switch to showing that canvas?



You want to refer to the canvas by array index as described in

For example, the first canvas is:

var cnvs =[0].selection.canvas

The second canvas down from the top is:

var cnvs =[1].selection.canvas

If you want to iterate over the canvases, you use logic like you would iterate over any array to get all of the canvases and act on them. The script Rename in Current Order in the Canvas Tools plug-in has a nice example.


Thanks for continuing to assist - I think that I’m not being very clear.

For example, the Actions property of an object include “Switch to the next canvas”. I’m not trying to change the properties of any of the canvases, or their order in the document; I just want OG to switch to showing a different canvas (especially in Presentation mode) just as it does when I use the up or down arrows, or one of those Actions.

Is that possible?

Many thanks,


You can add an action that calls a script if you like. There is a built in “Jump To Canvas” action in OmniGraffle, so you don’t need a script to jump between canvases unless you want something more specific than the 6 options we provide. Select the shape, in the Properties Inspector under Action, set “Jump to Canvas” from the Drop Down menu. Then you pick which canvas to jump to. To do the jumping, use the Action tool or go into presentation mode

If you select an object in OmniGraffle Pro, in the Properties inspector you can set an action to AppleScript or JavaScript, and then change to that canvas by clicking on that object with the action tool (Or in presentation mode). If you do need a custom scripting action, try setting the Current View to the canvas that you want in your script.


Aha! Thanks Lanette - that’s exactly what I wanted. Sorry to be so dense, I didn’t realise the distinction between the order of canvases in the document, and the order of canvases in the window.

(What I’m trying to do is have an object with an action that includes first jumping to another canvas, and then hiding and showing layers on that canvas - I can do either with the built-in actions, but to do both requires a script.)

Thanks for persisting when I didn’t get it!


Hi, just getting familiar with automation in omni and wondered if there’s any reason the above wouldn’t work anymore? The majority of the examples as well as sals tools/og tools - on don’t work and typically fall over when referencing the canvas. Returns an ‘undefined’ error. What am I doing wrong?

‘copy as’ code from a shape works, just not the above. All I’m trying to do is loop through the canvas to copy text.


See for the examples of the correct and incorrect way to reference a canvas. Keep in mind, this changes the canvas showing in the view (center), but it may work so fast that you can’t see it. Undefined isn’t actually neccisarily an error. Unless you define a value for your variable or function to return, undefined is the default. The script below will go through each canvas leaving you viewing the last canvas in the view of the frontmost window.

canvases.forEach(function(cs){[0].selection.view.canvas = cs;



It seems that referencing the canvas is the problem. I get the following error ‘ReferenceError: Can’t find variable: canvases undefined:1’ whenever I try to reference something, even when copying the code above.


Do you have a document open with multiple canvases when running this? Are you running it from the console inside OmniGraffle? Can you check which version of macOS (Apple menu->About This Mac) and OmniGraffle (OmniGraffle>About OmniGraffle) you are running so that I can make sure I am testing the same thing that you are? When I run the script above inside the OmniGraffle Automation Console, I see page 2 of the frontmost document and if I add a graphic, it is added to the last canvas in the document. I’ve tested this in multiple documents in OmniGraffle Pro 7.9.4 with both macOS 10.13.6 and 10.14 including the most recent beta. If these versions match what you are using, please contact support so that we can troubleshoot this with you. Please email us at


Looks like it hasn’t been updated since 7.7 and ‘check for updates’ was turned off. It works now! Thanks


Awesome! We keep adding more OmniJS support in most versions, so you may have been missing many updates. Glad you solved the mystery.