8

is there a good way of generating a visio diagram of an architecture (with a decent layout) if i have a list of client apps, services and databases? i would have thought there would be a decent way to generate this on the fly.

John Saunders
  • 157,405
  • 24
  • 229
  • 388
leora
  • 163,579
  • 332
  • 834
  • 1,328
  • 1
    'csharp' and 'dotnet' tags are just plain wrong here. You've been using the site for long enough you ought to know better. – Joel Coehoorn Feb 13 '10 at 20:19
  • i thought i read that these get resolved to the right ones through a recurring script – leora Feb 13 '10 at 20:25
  • 1
    I've had good results with Aspose.Diagram: http://www.aspose.com/.net/diagram-component.aspx – Adam Jul 02 '15 at 04:46

1 Answers1

7

There is VisioAutomation on GitHub. If you have Visio installed it can automate the generation of a diagram. If you can model the diagram you want as a directed graph then it can automatically layout the graph for you (using MSAGL).

Here is a basic example of creating the directed graph

        using VACONNECT = VisioAutomation.Shapes.Connections;
        var d = new VisioAutomation.Models.DirectedGraph.Drawing();

        var basic_stencil = "basic_u.vss";
        var n0 = d.AddShape("n0", "Node 0", basic_stencil, "Rectangle");
        n0.Size = new VA.Drawing.Size(3, 2);
        var n1 = d.AddShape("n1", "Node 1", basic_stencil, "Rectangle");
        var n2 = d.AddShape("n2", "Node 2", basic_stencil, "Rectangle");
        var n3 = d.AddShape("n3", "Node 3", basic_stencil, "Rectangle");
        var n4 = d.AddShape("n4", "Node 4\nUnconnected", basic_stencil, "Rectangle");

        var c0 = d.AddConnection("c0", n0, n1, "0 -> 1", VACONNECT.ConnectorType.Curved);
        var c1 = d.AddConnection("c1", n1, n2, "1 -> 2", VACONNECT.ConnectorType.RightAngle);
        var c2 = d.AddConnection("c2", n1, n0, "0 -> 1", VACONNECT.ConnectorType.Curved);
        var c3 = d.AddConnection("c3", n0, n2, "0 -> 2", VACONNECT.ConnectorType.Straight);
        var c4 = d.AddConnection("c4", n2, n3, "2 -> 3", VACONNECT.ConnectorType.Curved);
        var c5 = d.AddConnection("c5", n3, n0, "3 -> 0", VACONNECT.ConnectorType.Curved);

And then to draw it:

        var options = new VisioAutomation.Models.DirectedGraph.MsaglLayoutOptions();

        var page = visio_app.ActivePage;
        d.Render(page,options);
Community
  • 1
  • 1
Amirshk
  • 7,772
  • 2
  • 30
  • 61