OmniGraffle AppleScript export settings in 2021

Hello,

I am building a simple AppleScript that would export canvases of a document as an individual PNG files.

OmniGraffle version: 7.18.1 (v204.6.0)
MacOS version: 10.15.7

Googling and fiddling with examples I could build a script similar to the one below (I removed unessential canvas iteration lines and folder selection to simplify logic):

tell application "OmniGraffle"
  set pngFile to "/Users/juriy/temp/export/example.png"
  log "Saving file"
  save front document in POSIX file pngFile
end tell

However I could not find the way to export with double resolution. The examples that I found on this forum suggest several ways to do that, neither of which seems to work in 2021.

The following line runs without errors, but no file is produced:
export front document scope "current canvas" as "PNG" to POSIX file pngFile with properties {resolution:2.0, scale:1.0}

The following line, suggested in another thread crashes OmniGraffle (I later found out that current export settings is a read-only object):
set size of current export settings to {495.1111, 278.5}

Although current export settings are read-only, it is in fact possible to set some settings, but not the others. For example, if I am adding this line before saving, the borders are added to the resulting image:

set border amount of current export settings to 150

At the same time, attempting to set scale and resolution in the same way doesn’t have any impact on the result:

set resolution of current export settings to 2
set export scale of current export settings to 4

Please help. What’s the suggested way to set the export properties that works in 2021?

You might move this message into the Automation section. That group has more experience with AppleScript/JavaScript issues.

Also might want to include version of OG and MacOS you are using. Sometimes helps narrow down things.

Sorry I can’t be of more assistance.

Per the dictionary, ‘export scale’ must be a real number. Try setting it to ‘4.0’ instead of ‘4’. Same applies to ‘resolution’. Alternatively, you could coerce it by entering ‘to 4 as real’.

If I were to guess, the ‘current export settings’ are read only as a whole because you set the parts individually. But maybe it’s just confused or awkwardly written.

NB I am using OG v6 but I suspect it is the same

Sorry for the lack of clear diagnostics explaining what went wrong there! This command was on the right track, but you need to leave the script terminology keywords current canvas unquoted so they get parsed into the proper scripting events. (You’ll also want to reference export scale in the export settings, rather than scale.)

For example:

export front document scope current canvas as "PNG" to POSIX file pngFile with properties {resolution:2.0, export scale:1.0}

Hope this helps!