The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniGraffle > OmniGraffle General
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
AppleScript to query the user data key/value pairs Thread Tools Search this Thread Display Modes
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"}…
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
Any help would be appreciated.

Regards Alan
 
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
Hope it helps
 
Quote:
Originally Posted by apl View Post
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
Hope it helps
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
Thanks
Simon
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Applescript: user data item of canvas cyleigh OmniGraffle Extras 1 2011-05-04 08:59 PM
Custom text exports from OmniFocus (applescript-based query language) RobTrew OmniFocus Extras 0 2011-01-14 06:08 AM
Leveraging custom/user data fink08 OmniGraffle General 1 2009-11-12 07:08 AM
Finding a graphic using user data property Joe.Hocker AppleScripting Omni Apps 3 2009-03-26 11:03 AM
Sharing OF data across user accounts beelers OmniFocus 1 for Mac 0 2007-11-24 04:51 PM


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


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