View Single Post
Thorsander, you should also ask the OmniGraffle support ninjas directly, via Help->Send Feedback or email to omnigraffle@omnigroup.com. There's no guarantee they'll see and respond to a forum post, but they will definitely get the support email.

I think you can do what you want for your first question with a bit of Applescript. I'm not sure what that number you are displaying in your screenshot is. If it is the id of the graphic, I'll warn you that it is only unique to that canvas, not the document.

There's a dictionary for storing user-specified data on each graphic, called user data. To display a value from that dictionary, use the variable <%Userdata KEYNAME%> where KEYNAME is the key you used when adding the value.

The following snippet of Applescript will draw a rectangle on the selected canvas, populate the MyUniqueID field in the dictionary with the shape id, and add some text to display the value.

Code:
tell application "OmniGraffle Professional 5"
	tell canvas of front window
		set myShape to make new shape at end of graphics with properties {size:{234.0, 264.0}, origin:{70.0, 49.0}, text:{"<%Userdata MyUniqueID%>"}}
		
		set user data of myShape to {MyUniqueID:(id of myShape as number)}
		
	end tell
end tell
The following bit of code will loop through every graphic in the document and populate the dictionaries. You can paste that variable string into a handful of objects to see that it has done so.
Code:
tell application "OmniGraffle Professional 5"
	--Get the current document for later use 
	set currentDocument to document of front window
	
	--Get a list of the canvases
	set theCanvases to every canvas of currentDocument
	--Loop over each canvas
	repeat with aCanvas in theCanvases
		--Make sure that the current canvas is displayed 
		set canvas of front window to aCanvas
		
		--get a list of groups for this canvas
		set theGroups to every graphic of aCanvas
		
		--loop over each group/graphic
		repeat with aGroup in theGroups
			
			set user data of aGroup to {MyUniqueID:(id of aGroup as number)}
		end repeat
	end repeat
end tell
Rob should be along shortly to explain how to make this code run faster with references and where clauses :-)