The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniGraffle General (http://forums.omnigroup.com/forumdisplay.php?f=10)
-   -   AppleScript to query the user data key/value pairs (http://forums.omnigroup.com/showthread.php?t=18144)

apl 2010-09-27 07:12 AM

AppleScript to query the user data key/value pairs
 
Hi,

I've been working on a script to write values into the key/value user data dictionary available with shapes in the Pro version of OmniGraffle.

The syntax to do this is:

[CODE]make new shape with properties {text:"My Shape", url:"http://...", user data:{myKey:"myData"}
[/CODE]

Whilst I can get this data into OmniGraffle so that I can see it in the interface I can't get my head around how to construct a way of getting at them.

Here's what I'm trying to do:

set myShapes to shapes of canvas of front window whose myKey is "myData"

I get all sorts of errors about how it can't find/coerce etc. I know it has to be my limited ability to construct the right argument.

I can get the dictionary out with the following script:

[CODE]tell application "OmniGraffle Professional 5"
user data of graphic id 3 of canvas id 1 of document "Untitled" of application "OmniGraffle Professional 5"
end tell[/CODE]

Any help would be appreciated.

Regards Alan

apl 2010-09-30 02:16 PM

I managed to find a solution should anybody else try scripting with the key/value user data dictionary.

The following script fragment generates a list of shapes with the key/value pair of aURLkey and "Hello".

[CODE]tell application "OmniGraffle Professional 5"
set matchingShapes to shapes of canvas of front window whose value of user data item "aURLkey" is "Hello"
end tell
[/CODE]

Hope it helps

Simon Knight 2012-01-14 01:05 AM

[QUOTE=apl;86519]I managed to find a solution should anybody else try scripting with the key/value user data dictionary.

The following script fragment generates a list of shapes with the key/value pair of aURLkey and "Hello".

[CODE]tell application "OmniGraffle Professional 5"
set matchingShapes to shapes of canvas of front window whose value of user data item "aURLkey" is "Hello"
end tell
[/CODE]

Hope it helps[/QUOTE]

Yes it does - many thanks, I have been struggling to discover the syntax to write to a user defined key value pair and your code snip was a great help. My aim is to add user key pairs to existing shapes but to edit the data in a predefined shape I'm using:
[CODE]tell myGraphic
set the value of user data item "MyKey" to "Some Data"
end tell[/CODE]

Thanks
Simon


All times are GMT -8. The time now is 07:30 PM.

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