Simon Fell > Its just code > May 2010

Friday, May 14, 2010

A friend recently turned me onto Instaviz, a great iPhone / iPad diagraming tool based on graphviz. Graphviz lets you define your diagram as a set of nodes and connections, and it will perform the layout for you. I have something of an interest in being able to visualize your schema, and some lines of python code later, i had something that would generate a graphviz description of your schema, starting from a primary object, and with the option to go 1 or more levels deep from there. Here's an example for Opportunity, just 1 level deep. (click for full size version)

And here's the generated oppty.gv file that produces that graph. If you have Instaviz or one of the desktop viewers for graphviz, you can open the .gv file directly in those apps. (and/or you can use the commandline tools to generate a png or other formats).

Here's the actual python code, it uses beatbox to call the describeSObject API to discover the schema for your login. You run it as

python mypassword Opportunity > oppty.gv

Here's an even larger model that's 5 levels deep from Account - png rendering (ouch its 6MB), gv (33k)