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…
Demo…
[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.
Rosario – Import Visio documents in the diagrams.
Had some fun last weekend and past evenings with Rosario, DSL’s and Visio.
When you read the MSDN forums about Visio, Modeling and Tools, Team Architect and Rosario you see that there are often questions about Visio and the need for export functionality… see this search result list and these threads:
This answers, triggered me:
there is no way to export to Visio using the April CTP
David is right with his answer. Visio 2007 doesn’t have an XMI export and the April CTP doesn’t have a XMI import [yet!!??, haven’t heard anything about it but David Starr mentions it in this post Architecture Modeling in Rosario with Peter Provost, still wondering if you can make an general XMI export/ import while every tools uses it’s own version].
But, the Rosario UML diagrams are based on the DSL tools… so everything is possible :-)
So, after some hours of playing… here is the Visio Import Addin. [don’t think an export is prio 1 at this moment]
First create or open an activity diagram, right mouse click and select “Import Visio Diagram”…
Select the diagram you want to import and look at the result…
I know it’s a very simple diagram, but it works, it even tries to take make the same layout (I didn’t do anything with the position of the shapes after the import)..
So, now it’s time to answer that forum post :-)
I think it’s useful. It’s useful for us, we’ve got tons of activity diagrams in Visio...
Anyway, time to prepare myself for a trip to Italia… will show some code after this weekend.