The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniGraffle General (http://forums.omnigroup.com/forumdisplay.php?f=10)
-   -   Omnigraffle XML format parsing (http://forums.omnigroup.com/showthread.php?t=19381)

tmacgahan 2010-12-13 08:31 AM

Omnigraffle XML format parsing
 
Hello there omni community,

I believe I've done my due diligence to ensure this is not a repost, but feel free to smack me if it is.

I am trying to adapt omnigraffle for my own twisted purposes, and would like to be able to use Graffle as both a presentation layer and a reference document, but I would also like to extract pure graph data for use in my code. My code is only interested in links between nodes, node names, and possibly what a node contains.

Can anyone point me towards some kind of primer for the graffle xml format, so I can parse to my heart's content? Does anyone know if extracting these links is reasonably feasible?

whpalmer4 2010-12-13 07:51 PM

Do you see yourself using OmniGraffle as the creation tool, and your code extracting information for further processing? How about having your code be the creation tool, and emit an OmniGraffle document? DOT/GraphViz format might be your friend here. I know that Omni uses it for visualizing OmniFocus sync graphs, for example.

Instead of figuring out how to parse the XML, another route would be to write an Applescript for OmniGraffle which communicates with your program in a convenient fashion.

john.gersh 2010-12-14 05:36 AM

I don't know if there's a primer, but the just looking at the XML probably tells one enough for extracting nodes and edges. The overall format is an Apple plist; as usual, the link to the DTD for that is in the file header. The XML is pretty much self-documenting; the names of the various elements and properties are self-explanatory.

The important element is the GraphicsList, an array of plist dictionaries, one for each object.

Lines that connect shapes have head and tail properties whose values are the IDs of the shapes connected. If the drawing is just nodes and edges that's pretty much all you need.

User-defined properties for an object might be helpful, too. The Note tab in the Properties inspector lets you enter key-value pairs. Those show up as the UserInfo property of the object in the graffle file. That might help you add easily-parsable information that your code can use.

As whpalmer4 said, you can also write an Applescript to extract the information you need and write it to some format convenient for your code.


All times are GMT -8. The time now is 05:53 PM.

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