accessing text of grouped graphics via AppleScript

Heiko Wichmann Wichmann2 at gmx.de
Wed Dec 11 04:57:01 PST 2002


Hi there,

after some time of experimentation with that great app OmniGraffle, I found
a way to access the text 
of grouped graphics via AppleScript.
Just to let you know (in case you wanted to). Use it and be happy ;)

Regards,

Heiko
Wichmann

------------------------------------------------------------------------------------------------------------------

set globalGraphicNumberArray to {}
set globalNumberOfGraphics to 0
set globalGraphicID to 0

on getNumberOfSubGraphics(levelOneNum, levelTwoNum, graphicID)
	set retVal to 0
	tell front document of application "OmniGraffle"
		try
			if levelOneNum = 0 then
				if levelTwoNum = 0 then
					set retVal to the number of graphics of graphic id graphicID
				end if
			else if levelOneNum > 0 then
				if levelTwoNum = 0 then
					set retVal to the number of graphics of graphic levelOneNum of graphic
id graphicID
				else
					set retVal to the number of graphics of graphic levelTwoNum of graphic
levelOneNum of graphic id 
graphicID
				end if
			end if
		on error
			set retVal to 0
		end try
	end tell
end getNumberOfSubGraphics

-- make graphics (grouped and single) with text
tell front document of application "OmniGraffle"
	set shpOne to make new shape at end of every graphic with properties
{origin:{10, 10}, size:{65, 
50}, text:"Hello"}
	set url of shpOne to "grpItem"
	set shpTwo to make new shape at end of every graphic with properties
{origin:{10, 70}, size:{65, 
50}, text:"World"}
	set url of shpTwo to "grpItem"
	set shpThree to make new shape at end of every graphic with properties
{origin:{10, 150}, 
size:{65, 50}, text:"Space"}
	set shpRef to a reference to (every shape whose url is "grpItem")
	set shpGrouped to (group shpRef)
end tell

-- get text of graphics (grouped and single)
tell front document of application "OmniGraffle"
	set globalNumberOfGraphics to the number of graphics
end tell

repeat with i from 1 to globalNumberOfGraphics
	tell front document of application "OmniGraffle"
		set globalGraphicID to id of graphic i
	end tell
	if (getNumberOfSubGraphics(0, 0, globalGraphicID) > 0) then
		repeat with k from 1 to getNumberOfSubGraphics(0, 0, globalGraphicID)
			if (getNumberOfSubGraphics(k, 0, globalGraphicID) > 0) then
				repeat with m from 1 to getNumberOfSubGraphics(k, 0, globalGraphicID)
					tell front document of application "OmniGraffle"
						display dialog "3:" & k & ":" & m & ":" & text of text of graphic m of
graphic k of graphic id 
globalGraphicID as string
					end tell
				end repeat
			else
				tell front document of application "OmniGraffle"
					display dialog "2:" & k & ":" & text of text of graphic k of graphic id
globalGraphicID as string
				end tell
			end if
		end repeat
	else
		tell front document of application "OmniGraffle"
			display dialog "1:" & text of text of graphic id globalGraphicID as
string
		end tell
	end if
end repeat

-- 
+++ GMX - Mail, Messaging & more  http://www.gmx.net +++
NEU: Mit GMX ins Internet. Rund um die Uhr für 1 ct/ Min. surfen!




More information about the OmniGraffle-Users mailing list