How do i get a netlist from visio?

H

hapitide

I would like to get a connectivity list from a Visio drawing. I'm having
difficulty doing this. Is there a COM plug in or VBA script for this.

What I really need is something that generates a from to list of shapes in
a drawing. For example
Name Master From To
--- ----- ----- ---
Shape1 State
myTransition Transition Shape1 Shape3
Shape3 State

etc
 
J

J Kallay

There are a few nuances to this. For example, you are assuming that
myTransition can only connect two shapes, an assumption which I don't
believe is generally true (theoretically, I think you could have a one-to-n
or n-to-n connector).

The key is in understanding the Visio object model's Connect object. A
Connect object represents a connection between two shapes, such as between
the endpoint of a connector and a connection point it's connecting to
(there's a terminology issue here: there are connects, connectors, and
connection points, and they're all different!).

Shapes and pages both maintain a Connects collection. What you probably
want to do is iterate through your Shapes collection, and for each shape
interrogate its Connects collection. Check each Connects object's FromSheet
property. If the result is the shape itself, then that shape is gluing TO
something else. Get that "something else" using the Connect's ToSheet
property.
In your example below, Shape1 and Shape3 would both have one Connect object,
and in both cases the FromSheet property would produce the myTransition
shape. So your method would ignore these (since the FromSheet is not the
shape itself). myTransition would have two Connects objects, and in each
case it would be in the Connect's FromSheet property. One of the Connects
would have Shape1 as the ToSheet and the other would have Shape3.

If the connection is undirected, just make whichever ToSheet you get first
as the From shape. If direction matters, I believe you need to check the
Connect's FromCell to see whether it's BeginX or EndX. This tells you which
endpoint of the Transition shape that particular connection is on.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top