Using visConnectionPoint data

C

Codebusters

Hi,

I've looked at all MS documentation about visConnectionPoint, but I still
can't solve my problem:

My VB program will get all the FromPart and ToPart info of a Visio document,
and also the connects and connection points, and write them all to an Access
table. After I do some processing in Access, my goal is to re-draw the Visio
exactly as the original using the PinX, PinY, and connects information I
already have.

The program re-draws the Visio shapes just fine, placing them exactly as
before. It also makes the correct connections, going from the begin to the
end shapes as expected. The only problem is that the begin and end
connection points do not get placed as in the original. They get connected
in some order I think is just random. The result is a lot of criss-crossed
lines and the document looks untidy.

The connection points that are retrieved by the method are 1, 2, 3, and 4,
which I believe means Left, Top, Right, and Bottom. It seems intuitive, but
I'm wondering now whether this is correct.

If anyone has any thoughts or experience with this, I would really
appreciate your help.

Thanks,

Regards,

RB
 
J

JuneTheSecond

If those connection points are on the child shapes of any grouped shape,
program may not find those connection points unless otherwise program access
the child shapes.
 
C

Codebusters

Hi JuneTheSecond (cool name !!)

Thanks for the reply, but my shapes are not grouped. Each is individual,
and most of the time it is a Process box, or Decision, or Terminator. Very
simple layout, except that the whole document can sometimes be more than 10
pages. Average number of pages is 3-4.

Any other suggestion you have would be really helpful.

So you agree with me that the points 1,2,3,4 represent left, top, right,
bottom?

Again, thanks for looking into this.
 
A

Andy

Then, would you tell us more how did you connects in you program.

The order of the connects is likely to be the order in which you
originally connected the lines to the shape. The easiest way I found
was to name my connection points, you can store the row name for the
connection point and use this when you are reconnecting.
 
C

Codebusters

Hi JuneTheSecond,

That's a great suggestion, to name the connection points. However, our
business process is such that we get the Visio's from our clients already
drawn. Re-training them to name connection points is not feasible in the
short-term.

Here's the code below for how I retrieve the info, and draw the visio (I got
it from MS docs):

FIRST PART:

For Each connection In connections

shapeFrom = connection.FromSheet
shapeFromNameU = shapeFrom.NameU
fromIntegerData = connection.FromPart

If (fromIntegerData < Visio.VisFromParts.visControlPoint) Then
fromData = CType(fromIntegerData, Visio.VisFromParts)
fromStringData = fromData.ToString()
Else
fromStringData = "visControlPoint" _
& CStr(fromIntegerData -
Visio.VisFromParts.visControlPoint + 1)
End If

shapeTo = connection.ToSheet
shapeToNameU = shapeTo.NameU
toIntegerData = connection.ToPart

If (toIntegerData < Visio.VisToParts.visConnectionPoint) Then
toData = CType(toIntegerData, Visio.VisToParts)
toStringData = toData.ToString()
Else
toStringData = "visConnectionPoint" _
& CStr(toIntegerData -
Visio.VisToParts.visConnectionPoint + 1)
End If

SECOND PART:

vConnPoint =
Microsoft.VisualBasic.Right(reader21(4).ToString, 1)
If vConnPoint = "1" Then
vConnPtStr = "AlignLeft"
ElseIf vConnPoint = "2" Then
vConnPtStr = "AlignTop"
ElseIf vConnPoint = "3" Then
vConnPtStr = "AlignRight"
ElseIf vConnPoint = "4" Then
vConnPtStr = "AlignBottom"
Else
vConnPtStr = "AlignTop"
End If

vFlowChartMaster = vStencil.Masters(vEndShp)
vToShape =
currentPage.Drop(vFlowChartMaster, vEnddblX, vEnddblY)
vToShape.Text = vEndQTxt

vConnectorMaster = vStencil.Masters("Dynamic
Connector")

vConnector =
vApp.ActivePage.Drop(vConnectorMaster, 0, 0)
vConnector.Text = vAnsTxt
vBeginCell = vConnector.Cells("BeginX")
vBeginCell.GlueTo(vFromShape.Cells(vConnPtStr))
vEndCell = vConnector.Cells("EndX")
vEndCell.GlueTo(vToShape.Cells(vConnPtStr))
vConnector.SendToBack()



This is not all of the code -- I just sent you the relevant parts.

Thanks for looking at this.
 
A

Al Edlund

It sounds as if your issue is layout and routing. For a start I'd go check
the visio blog at
http://blogs.msdn.com/visio/
for some discussions on glue/connect. If you're attempting to duplicate what
the original looked like
you might consider for the connections to copy the geometry sections (which
is where the real layout
is stored). I'd probably have two tables in my access database (one for
connections keyed on the id, and
one for the geometry keyed to the connection id's) Then when you restore you
just drop the connection and
write over the geometry.
al
 
C

Codebusters

AL, thank you for the suggestions. I'm going to try them out, and I think
they'll work as you described.

Look for a posting here of how this worked out.

Thanks again.
 

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