The canvas is the big white area in the center of OmniGraffle’s interface where you draw and create things. An OmniGraffle project (document) always contains at least one canvas and one layer.

An OmniGraffle document can contain many canvases, of varying sizes and with a variety of properties and settings. For example, an OmniGraffle document may contain a canvas that is 1600 points by 1200 points, a canvas that is 768 points by 1024 points, a canvas that is 400 points by 400 points, and even a canvas that adjusts its size to fit the objects drawn upon it.

In the document window’s sidebar (on the left), canvases are displayed as a list with the topmost canvas in the list having the lowest numeric position, which is the first cavas, but in JavaScript terms, has a 0 index. In the image below, the OmniGraffle document has four canvases, with the canvas named “Canvas 1” at the top of the list of canvases. In JavaScript, it would be identified as: canvases[0]

document sidebar canvas list

The last canvas in the list of canvases, the one named “Canvas 4” is identified in JavaScript as canvases[3]

Also, as an aide for precision, a canvas can display a grid that optionally may cause drawn or imported objects to snap to its lines.

Canvases in OmniGraffle are totally flexible in their implementation and abilities. This section examines how to script canvases in OmniGraffle.

DO THIS ► Install the  Canvas Tools  plug-in, a collection of actions for manipulating canvases in OmniGraffle.

The Current Canvas

Many of your scripts will probably be designed to work with objects selected by the user. If a document has five canvases, your script cannot assume that the canvas currently being worked on by the user, is the topmost canvas. Scripts need to know what is the “current canvas.”

In the image above, the current canvas is named “Canvas 3.” However, since scripts can’t “see” the application interface, they have to derive the current canvas by asking for the canvas object that is the value of the canvas property of the document window’s selection. In scripting the “current canvas” can be derived with this script statement:

cnvs =[0].selection.canvas

Canvas Reference

Canvases are an element of the Portfolio class, an invisible representation of the current document, and therefore do not need to referenced by their position in the document hierarchy within scripts. In other words, instead of entering:


to indicate the topmost canvas, you simply enter:


(TIP: see the Big Picture page for more details).

Selecting Canvases

An instance of the canvas class can be assigned as the value for the canvas property of the document selection object. In that way, you can select each of the existing canvases one-at-a-time:

var docView =[0].selection.view canvases.forEach(function(cnvs){ docView.canvas = cnvs console.log( })

or even select a specific canvas by name:

var docView =[0].selection.view var targetName = "Tulip" var flag = true canvases.forEach(function(cnvs){ if(flag && == targetName){ docView.canvas = cnvs flag = false } })

Here’s a plug-in that will select the canvas chosen from the presented menu of canvas titles:

/*{ "type": "action", "targets": ["omnigraffle"], "author": "Otto Automator", "identifier": "", "version": "1.0", "description": "Selects the canvas chosen from menu of canvas names.", "label": "Select Chosen Canvas", "shortLabel": "Select Canvas" }*/ (() => { var action = new PlugIn.Action(function(selection, sender){ // action code // selection options: canvas, document, graphics, lines, solids, view var canvasObjects = new Array() var canvasTitles = new Array() var menuIndexes = new Array() canvases.forEach((cnvs, index) => { canvasObjects.push(cnvs) canvasTitles.push( menuIndexes.push(index) }) var canvasesMenu = new Form.Field.Option( "canvasesMenu", null, menuIndexes, canvasTitles, 0 ) var form = new Form() form.addField(canvasesMenu) var formPrompt = "Choose the canvas to select:" var buttonTitle = "Continue" var formPromise =, buttonTitle) // PROCESS THE FORM RESULTS formPromise.then(function(formObject){ // RETRIEVE CHOSEN VAUES var menuIndex = formObject.values['canvasesMenu'] var chosenCanvas = canvasObjects[menuIndex] var docView =[0].selection.view docView.canvas = chosenCanvas }) }); action.validate = function(selection, sender){ // validation code // selection options: canvas, document, graphics, lines, solids, view return true }; return action; })();

Add a Canvas

And because canvases are an element of the Portfolio, you use the addCanvas() method of the Portfolio class to create a new canvas. The result of that method is a reference to the newly created canvas, which can be stored in a variable to reference the canvas later in the script.

cnvs = addCanvas() cnvs.size = new Size(1600, 1200)

In the example script above the value of the canvas’ size property is set by creating a new Size object using the desired canvas width and canvas height, in points. Scripts always use points when getting and setting the size of a canvas.

If storing a reference to the created canvas is not essential, you can combine the creation and setting of canvas dimensions into a single-line script, as shown in the example below:

addCanvas().size = new Size(1600, 1200)

Delete a Canvas

To delete a canvas from the document, use the remove() method on an instance of a canvas. The following example script deletes the current canvas after checking that there are multiple canvases in the document:

if (canvases.length > 1){ cnvs =[0].selection.canvas cnvs.remove() }

To delete a contiguous series of canvases, start with the last and iterate to the topmost canvas, as shown in this script that removes all canvases except the top one:

for(var i = canvases.length; i--;) { if(i != 0){canvases[i].remove()} }

Name a New Canvas

The name property of a canvas can be read and changed. The following scrpt is an example of creating a new canvas whose name is, or an incrementation of, a specific name. More naming examples are on this page.

cnvs = addCanvas() baseName = "My Canvas Name" versName = "My Canvas Name" cnvsNames ={return}) counter = 0 while (cnvsNames.includes(versName)){ counter = counter + 1 versName = baseName + "-v" + String(counter) } = versName

Move a Canvas

Canvases can be reordered within the stack of canvases. To change the stack position of a canvas, use the orderBefore() and orderAfter() methods. These instance methods take a direct parameter that is an object reference to canvas that the moved canvas is placed before or after.

In the following example, the current canvas is moved to the top of the stack of canvases. Note the conditional statement (line 3) that compares the value of the id property of the current canvas with the value of the id property of the top canvas, to ensure that the current canvas is not already the topmost canvas.

if (canvases.length > 1){ var cnvs =[0].selection.canvas if( != canvases[0].id){ cnvs.orderBefore(canvases[0]) } }

And the example below uses the orderAfter() method to move the current canvas to the bottom of the stack of canvases. This script also performs a compariosn using the canvas id property (line 3) to ensure that the canvas to be moved is not already the bottom canvas.

if (canvases.length > 1){ var cnvs =[0].selection.canvas if( != canvases[canvases.length-1].id){ cnvs.orderAfter(canvases[canvases.length-1]) } }

Move and Delete

In this example script, the orderBefore() and the remove() methods from the Canvas class are used to essentially delete every canvas except the one that is the current canvas.

This task is accomplished by first moving the current canvas to the top, and then deleting the remaining canvases starting at the bottom and iterating to the top. Note the conditional statement (line 3) that compares the value of the id property of the current canvas with the value of the id property of the top canvas, to ensure that the current canvas is not already the topmost canvas.

if (canvases.length > 1){ var cnvs =[0].selection.canvas if( != canvases[0].id){ cnvs.orderBefore(canvases[0]) } for(var i = canvases.length; i--;) { if(i != 0){canvases[i].remove()} } }

Other Canvas Instance Methods

The following instance methods of the Canvas class are covered in other sections of this website. Click|Tap on the method name to go the related page.


This webpage is in the process of being developed. Any content may change and may not be accurate or complete at this time.