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

 
How to create key-value pairs when creating a shape Thread Tools Search this Thread Display Modes
I have an AppleScript that creates a shape with a variety of properties. I have noticed that Omnigraffle 5 has the ability to create key-value pairs to store additional user-defined information, and I would like to do this programmatically (using AppleScript). But I cannot figure out the syntax. Can anyone help me?

Here is how I am currently creating my shapes:
"
on makeShape(aTitle)
tell application "OmniGraffle Professional 5"
tell canvas of front window
return make new shape at end of graphics with properties {text:aTitle, vertical padding:5, autosizing:full, side padding:10, magnets:{{0.5, 0}, {-0.5, 0}, {0, 0.5}, {0, -0.5}}, origin:{(x of canvasSize) / 2.0, (y of canvasSize) / 2.0}}
end tell
end tell
end makeShape
"
I would want to add things like type="node" or author="ian" and various other terms.

Thanks,


Ian.
--
 
The following should work:

{user data: {foo: "bar"},

Put that in the properties in your script and you should be good to go.
__________________
"Vroom! Vroom!!"
 
Quote:
Originally Posted by Joel View Post
The following should work:

{user data: {foo: "bar"},

Put that in the properties in your script and you should be good to go.
Thanks Joel.

I wasn't sure about exactly where you meant I should put the braces, but I tried this and it didn't seem to have an effect (the blue text is what I have added: I am passing a string in as the id in this case, and want that to be the value for a key called "termId").

I would really like to have a bit more control over the shapes and layout as I create them - is there somewhere I can read the documentation for how to call things like Orthogonal line types, fill colours for shapes, drop shadows, layout types and so on?

AppleScript snippet:
return make new shape at end of graphics with properties {text:aTitle, url:aUrl, user data:{termId:aId}, vertical padding:5, autosizing:full, side padding:10, magnets:{{0.5, 0}, {-0.5, 0}, {0, 0.5}, {0, -0.5}}, origin:{(x of canvasSize) / 2.0, (y of canvasSize) / 2.0}}


Ian.
--
 
Quote:
Originally Posted by ianpiper View Post
Thanks Joel.

I wasn't sure about exactly where you meant I should put the braces, but I tried this and it didn't seem to have an effect (the blue text is what I have added: I am passing a string in as the id in this case, and want that to be the value for a key called "termId").

Ian.
--
Joel,

<blush>I just checked it again and your suggested approach does work</blush>

It would still be nice if there were some documentation that I could look at for this. If the API is documented for any language somewhere I would be happy to work out the relevant calls for AppleScript. Is there such a beast?

Thanks again for your help,


Ian.
--
 
The OmniGraffle AppleScript Dictionary should have all of this documented (I think), however one of the far easier ways to get at this stuff is to create it in Graffle, then copy it as AppleScript from the Edit Menu --> Copy As submenu.

Cheers,
__________________
"Vroom! Vroom!!"
 
Joel,
Once I attach the data to a shape using the Key Data Fields, is there a way to get it out of the drawing?
I'm using OGP5 to annotate floorplans for wire locations and types.
I built a Stencil with my symbols for each type of equipment and put the same Key Data fields in each shape, so when I drop a symbol on the floorplan I can input wire type, number and location information.
Would be great if I could create a table on a page that would pull out the data fields and show them!
I'll settle for an export to CSV, or TXT files though!
 
You may want to take a look at the .graffle file format itself (uncompressed). It's an XML property list, and you may be able to post-process the document if you're so inclined.

We do have a number of feature requests to have that data export to other formats, as an FYI.
__________________
"Vroom! Vroom!!"
 
Joel! You're here!
Thanx for that info!

Is there a way to copy the key data fields from one shape to another?
Sort of like painting withe the properties brush?
 
There isn't, however that does sound like a very good idea.
__________________
"Vroom! Vroom!!"
 
Joel.
I'm baaaack! Hey, was working on another system design and ran across the data pairs question again, did a search and found my own post, sucks getting old, you forget things.

I was wondering if there was a way have one of the key data pairs (or more) show up on the symbol itself. Sort of like the variables being used to add dates and file names ad such to drawing pages.

Any idea if this is possible? Would be great for marking up drawings, drop a part symbol on the drawing fill in the data and have the part number and wire number appear on the symbol in the drawing.

Does that make sense??
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Possible to Create Spatial Offset from Line to Shape/Object? acowan OmniGraffle General 3 2013-01-03 10:00 PM
AppleScript to query the user data key/value pairs apl OmniGraffle General 2 2012-01-14 02:05 AM
Create new smart shape? ramatsu OmniGraffle General 0 2010-10-26 10:55 PM
Need help creating a script for creating a next action gcrump OmniFocus Extras 9 2009-02-21 07:10 PM


All times are GMT -8. The time now is 12:22 AM.


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