The Omni Group Forums

The Omni Group Forums (
-   AppleScripting Omni Apps (
-   -   Getting Groups from Graffle (

RobLewis 2009-05-02 10:09 AM

Getting Groups from Graffle
Aargh. What am I doing wrong???

I have nested groups in an OmniGraffle document. The following code (and many variations thereof):

tell application "OmniGraffle Professional 5"
tell front document
tell canvas 1
set group_list to every group --gets top-level groups only?

repeat with a_group in group_list
set subgroup_list to {}
tell a_group to set subgroup_list to its every group
display dialog subgroup_list as text
end repeat

end tell
end tell
end tell

tells me that [B]the variable subgroup_list is not defined[/B].
[I]At the very least[/I], shouldn't it be defined as an empty list? (The "set subgroup_list to {}" line was a desperation measure that shouldn't be needed.)

More importantly, why is it not finding the subgroups in my groups?

Brian 2009-05-04 04:38 PM

If you specify a type for subgroup_list (change that line to "every group [B]as list[/B]") your existing script won't throw that error. (at least on my 10.5.6 box, it doesn't.)

Since you're asking the canvas for a list of the groups that it contains, you're only getting the top level groups that are actually owned by the canvas.

We're quickly reaching the upper limit of my AppleScript knowledge, but it sounds like you want to ask each group if it contains any subgroups, then gather info on them as appropriate.

RobLewis 2009-08-25 07:50 AM

OK, if I have to put "as list" in that line, why don't I have to also put it in the line:
set group_list to every group --gets top-level groups only
Seems rather arbitrary and inconsistent.

RobTrew 2009-08-25 01:21 PM

The canvas object has a list called [B]groups[/B]
but the sub-group list of any group is just [B]group[/B] (no final s)

You could get a list of grouped objects by referring, for example to:
[CODE]group of item 1 of group of group 1 of canvas 1 of document 1[/CODE]


RobLewis 2009-08-25 03:52 PM

OK, now my head hurts.

According to OG's scripting dictionary, "canvas" contains "groups" (plural). Also, "group" contains "groups" (plural). So if I get every group in a group, shouldn't it automatically return a list of them? Isn't that what "every" means? Why can I get a list of every (top level) group in a canvas, but not in a group?

What am I missing?

RobTrew 2009-08-25 11:43 PM

[QUOTE=RobLewis;65208]According to OG's scripting dictionary ... "group" contains "groups" (plural)[/QUOTE]

Not as far as I can see ... (OG Pro 5.1.1)

A group appears to consist of a list of graphic objects, each of which has a group (a list, which may be empty, of further graphic objects).

Have you tried taking a look through [URL=""]Script Debugger[/URL]'s Explorer ?


All times are GMT -8. The time now is 04:09 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.