/python-visio-diagram-generator

Python code for generating a diagram using MS Visio based on a set of hierarchically nested objects.

Primary LanguagePython

Python Visio Diagram Generator

This is some code for drawing a basic Visio diagram illustrating a set of hierarchically nested objects using Python. Currently it can only draw a hierarchy 3 levels deep, with a single root object, all centered around a single horizontal line. I plan to update this code to support deeper trees drawn in a more versatile and aesthetically pleasing manner.

The code takes a python dictionary representing a tree of hierarchically nested objects (see capability_map.py), which looks like this: capability_map = { 'Customer Travel Experience' : ['Pre- and Post - Travel Experience', 'Check-In Desks Management', 'Gate Departure Management','Customer Airport Services'], 'Pre- and Post - Travel Experience': ['Customer Products and Marketing', 'Sales', 'Customer Pre-Travel Experience', 'Access and Transportation', 'Customer Relations', 'Customer Loyalty Management'], 'Check-In Desks Management': ['Luggage Acceptance', 'Passenger Information Management'], 'Gate Departure Management': ['Outbound Flight Planning', 'Data Control Management', 'Passenger Boarding Management', 'Flight Closeout and Post Departure Management'], 'Customer Airport Services': ['Retail Management', 'Lounge Services Management', 'Customer Special Needs Services Management'], 'Customer Products and Marketing': [], 'Sales': [], ... }

...And turn it into a Visio diagram which looks like this:

"output"

There is also an example provided for you to test out the code. Thanks to [Orbus Software](https://www.orbussoftware.com/resources/starter-packs/togaf-92-starter-pack/) (where I work) for the stencil.

I'm sharing this on Github for a few reasons:

  1. It might actually be useful to someone out there as is :)
  2. There is a real lack of existing examples and documentation online regarding how to write python code which manipulates Visio. That's a shame, because it seems that Python can be quite powerful for this use case. I encourage any other Python + Visio users out there to get inspired and make your own projects and share them with me. It would be great to create a toolbox of some open source Python projects for doing cool Visio stuff. Anyone interested in contributing towards this effort contact me at dlcohen@gmail.com!
  3. The code as is works pretty nicely as is, but is still a tad buggy (run the example to see what I mean). If anyone has any ideas how to improve it, I'd love to hear!

    How to run
  • Download or clone the repository to your local machine.
  • In your command line terminal, navigate to the project folder using cd.
  • Enter the command python diagram_generator.py to run the code on the provided example data.
  • To use this code for a custom project, edit capability_map.py to reflect your data set, and the arguements in diagram_generator.py to reflect the paths of the stencil and template on your machine as well as the desired output path.