Hi,
I have also been working on an export script, but with a little different flavor. I use OG 4 to draw a bunch of buttons/icons in one canvas.
Then, in the "Note" for each object I want to export I put the
text "ExportTo[filename]"
Anyway, this seems to work, and as it wasn't very obvious to me (an intermittent Applescripter at best) I post it here in case its useful:
(ps. if anyone has a simple way to do regular expressions in Applescript
on the note contents would be nice to simplify into
filename = first group of match regex "exportTo[.*?]" on string this_note
or something like that!
Code:
tell application "OmniGraffle Professional"
set myWindow to front window
set myDoc to document of myWindow
set export_folder to (choose folder with prompt "Pick the folder to export icons to process") as string
set exportType to "PNG"
set exportFileExtension to "png"
--copy current export settings to mySettings but I cant restore...
set allProps to properties of current export settings
set include border of current export settings to false
set copy linked images of current export settings to false
set area type of current export settings to selected graphics
tell front document
activate
repeat with i from 1 to number of items in every canvas
set this_canvas to item i of every canvas
set canvas of myWindow to this_canvas
tell canvas i
set allGraphics to (every graphic whose notes contains "ExportTo[")
repeat with i from 1 to number of items in allGraphics
set this_item to item i of allGraphics
set this_note to notes of this_item
set this_userData to user data of this_item
set this_tag to tag of this_item
-- Check if regex ExportTo[xxxx] exists in the note
-- and set file name to export to that name
set startIndex to offset of "ExportTo[" in this_note
set subString to texts from (startIndex + 9) to length of this_note
set endIndex to offset of "]" in subString
set fileName to texts 1 thru (endIndex - 1) of subString
set selection of myWindow to {this_item}
set exportFileName to export_folder & fileName & "." & exportFileExtension
save myDoc as exportType in exportFileName
end repeat
end tell
end repeat
end tell
end tell