View Single Post
Quote:
Originally Posted by timwilson View Post
Let's say I wanted to create an AppleScript that would look in the current document for a graphic element with user data: {name: "mgsh"} and set its fill color to blue.
I haven't managed to query on the contents of the user data record, but you can query on the contents of the notes field.

If you place your identifier string in the the note of the graphic, you can retrieve the graphic(s) with notes containing that string:

Code:
tell application "OmniGraffle Professional 5"
	tell first canvas of first document
		
		set lstShapes to shapes where notes = "mgsh"
		if length of lstShapes > 0 then
			set oShape to first item of lstShapes
			-- set properties of oShape here
			
		end if
		
	end tell
end tell
If you need to reserve the notes for other purposes, then iteration is probably the only route, but you can restrict the list of shapes through which you have to iterate by querying for those which do actually have user data.

Code:
set lstShapes to shapes where user data is not missing value

Last edited by RobTrew; 2010-03-06 at 12:46 AM..