How to create a Visio Importer for Team Architect Rosario

First a small video to show how it works, second some explanation how to do it…


[recorded with camstudio and my birthday present ;-) ]

You can download the video from my SkyDrive

How to make one yourself…
I think Visio isn’t the only format you want to import so here is a brief explanation how to make your own importer.

You have to figure-out what the format is, with Visio that was pretty easy. As you probably have seen in the video I saved the diagrams as VDX “Visio Drawing XML”. So the format I need to read is XML and MSDN made it even more easy for me to understand the structure. see this page on MSDN: Microsoft Office Visio 2007 XML Schema Reference.  


Next, create a Visual Studio Add-in [see this post “Rosario – Create Custom Team Architect UML Diagram-MenuItems ”]. I do think, that making use of the Backplane [Designer Bus] would be a better way to make this kind of functionality, for sure we don’t get the question anymore to reload the diagram after importing… but the activity diagram isn’t connected to it, maybe in a different release. Till that time an add-in is the most easiest way.

Create an object model which gets the information from the Visio-diagram.  The VisioReader method reads the diagram and loads the model with a collections of shapes and connectors [this piece of code needs some refactoring]. As you can see I only grabbed some basic values, the connector should have Guards for example.


Anyway, when you got the Visio diagram in memory we need to put it on the diagram…   First get the model [see below and click for a bigger picture ]. Create a store and load the model, I not only loaded the model but also the diagram [see the methode “LoadmodelandDiagram” in the SerializationhelperClass] this gives me the opportunity to position the shapes on the design surface, it even gives the possibility to change the size and colors...  maybe I should change the color of the imported shapes in red… 


When you got the model and diagram, start a new transaction and iterate through your shapes collection…  and draw the shapes.
Below the drawing of the finalshape. As you can see the code for the position is a bit crabby.


and finally draw the lines, commit the transaction and save the result…



There is a lot more work to be done to make it more professional… but everything is in place to accomplish that.

Add comment

Şarkı Sozleri