View Single Post
Looks to me as if you may indeed have hit a bug in the implementation of OmniGraffle's Applescript library.

I would report it through OG's main menu:
Help > Send Feedback ... including a link to the url of this thread.

The second half of the following code fails (Applescript can get references to individual graphics on unshared layers but not on shared layers).

Code:
tell application id "OGfl"
	set oWin to front window
	tell front document
		repeat with oCanvas in canvases
			repeat with oUnsharedLayer in (layers of oCanvas where class is not shared layer) as list
				-- harvest from unshared layers of each Canvas
				set lstID to id of graphics of oUnsharedLayer
				repeat with lngID in lstID
					set lngID to contents of lngID
					graphics of oUnsharedLayer
					
					-- WORKS 
					set oGraphic to graphic id lngID of oUnsharedLayer
					set selection of oWin to {oGraphic}
					selection of oWin
					{}
				end repeat
			end repeat
		end repeat
		
		set oCanvas to front canvas
		tell oCanvas
			repeat with oSharedLayer in (layers where class is shared layer) as list
				-- harvest each shared layer from just one of the canvases which parent it
				set lstID to id of graphics of oSharedLayer
				repeat with lngID in lstID
					set lngID to contents of lngID
					graphics of oSharedLayer
					
					-- BOTH FAIL -- BUG IN OG APPLESCRIPT ?
					set oGraphic to graphic id lngID of oSharedLayer
					set oGraphic to graphic id lngID of oCanvas
					
					set selection of oWin to {oGraphic}
					selection of oWin
					{}
				end repeat
			end repeat
		end tell
	end tell
end tell
There may be a clue in these two screen dumps from Script Debugger. The Applescript library is not offering a properly resolved reference to the canvas from shared layers (<<class >> rather than canvas)



In contrast, this works properly from ordinary layers:

Last edited by RobTrew; 2011-12-07 at 08:49 PM..