Canvas Order Rename based on Selection?


Our team is looking for some guidance on adding a plugin that will go through each Canvas and append the existing name of the Canvas with a two-digit number. Specifically something like this format ’01.01 - ’ and count up from there. So if we had 6 Canvas’ in the document it would append the name of the 6 Canvas’.

01.01 – Canvas1

01.02 – Canvas2

01.03 – Canvas3

01.04 – Canvas4

01.05 – Canvas5

01.06 – Canvas6

What would be ideal is if we could select the Canvas we need auto-numbers and the starting value of the number. So if I select the first 3 Canvas’ and run the script, it prompts the starting number, I enter ‘1’ it would append the name of the Canvas for JUST the first 3. I select the 2nd half of the document (Canvas 4-6) and run the script and put my starting value as ‘2’. So it would look like this:

01.07 – Canvas1

01.08 – Canvas2

01.09 – Canvas3

02.01– Canvas4

02.02– Canvas5

02.03– Canvas6

I emailed support and they provided this script, which works to rename ALL Canvas’ but not just the Canvas I select. Plus, it doesn’t prompt for a start value, I.e. if I want to start numbers from 02.x or 03.x.

tell application “OmniGraffle”

tell front document

set myCanvases to ( every canvas as list )

repeat with i from 1 to (length of (myCanvases as list ))

set theName to (name of item i of myCanvases) as text

set thePrefix to “01.” as text

if (i is less than 10) then

set thePrefix to (thePrefix & “0”) as text

end if

set thePrefix to (thePrefix & (i as text ))

set theName to ((thePrefix & " - " & theName) as text )

set (name of ( item i of myCanvases)) to theName

end repeat

end tell

end tell

Any tips?