PDA

View Full Version : Applescript and groups


cyleigh
2011-02-06, 02:54 PM
I wish to traverse each group in my OG document. I have the following code:

tell application "OmniGraffle Professional 5"
set myGraphics to graphics of (canvas of front window)
repeat with g in myGraphics
set myGroup to group of g
if (myGroup is not missing value) then
repeat with g1 in graphics of myGroup
-- do some stuff
end repeat
end if
end repeat
end tell


I get the result that "myGroup" is not defined; I thought the whole point of testing for missing value is to check for defined? (ie/ null check). The if statement doesn't work the other way either (ie, check for missing value).. what am I doing wrong?

whpalmer4
2011-02-06, 05:09 PM
Yeah, that doesn't quite do what you want. Here's an example that works better:


tell application "OmniGraffle Professional 5"
set allGroups to every graphic of (canvas of front window) whose class is group
repeat with _group in allGroups
repeat with _graphic in graphics of _group
set draws shadow of _graphic to false -- turn off shadow for grouped objects
end repeat
end repeat
end tell



Some of these things are challenging to figure out without using something like the Explorer in Script Debugger...

cyleigh
2011-02-07, 04:00 PM
Thanks. Script Debugger is very helpful, now to convince the powers to be to spend money on it!