arrow direction of the line-curve connector

Z

ZeroVisio

Hi,

I'm trying to get shape information from visio. I have been to get the shape
information from visio. But I'm having trouble to figure out on which side of
line-curver connector is arrowhead? I'm trying this in c#. has anybody come
across this issue. Can someone help/share the code?
 
Z

ZeroVisio

I'm able to get tosheet, fromsheet, fromcell and that kind of onfo. What I'm
not able to figure out is beginarrow/endarrow..

thanks in advance...
 
D

David Parker

The cells you want are BeginArrow and EndArrow.

They are obviously on the connector line, and so you will need to decide
which end you want to have which arrow head. One way is to check which end
is connected to what. Unfortunately, the Connect object does not give you
all of the cells directly, so you have to read the ToSheet or FromSheet,
along with the ToCell or FromCell, to see where it is connected to. You can
check where the BeginX or EndX cells are connected to and decide if the line
is actually going in the direction you expect, and thus what arrow heads to
use.

There is also a function SwapEnds that conveniently allows you to
programmatically reverse the line, if required.
 
Z

ZeroVisio

Hi David,

thanks for your reply. I'm not clear by what you are saying. Could you tell
how to figure out where beginx and endX cells are connected to? Even when I
change the direction of arrow between the two boxes, fromcell, tocell,
fromsheet, and tosheet remain unaffected.

Could you please elaborate? Thanks in advance.
 
D

David Parker

I had a feeling that you would say that.
If you have a connector between ShapeA and ShapeB, then select the connector
and run the following VBA, then an arrow head will be added to the
connector.

Public Sub AddEndArrow()
Dim cnx As Visio.Connect
Dim shp As Visio.Shape

Set shp = Visio.ActiveWindow.Selection.PrimaryItem
If Not shp.OneD = 0 Then
For Each cnx In shp.Connects
Debug.Print cnx.ToSheet, cnx.FromCell.Name
If cnx.FromCell.Name = "EndX" Then
shp.Cells("EndArrow").Formula = "=5"
End If
Next cnx
End If

End Sub

I'll leave the conversion to C# to you.
 
Z

ZeroVisio

Hi David,

Thanks for the details!

My goal was to get the information from the visio file. I'm not making "any"
chnages to the shpaes in visio. But I was able to figure out how to get the
begin and end arrow values using get_CellsSRC method as follows:

if(shape_V.OneD !=0) //to check whether shape is a connector or not
{

//Code to get arrowhead value
String beginArrow =
shape_V.get_CellsSRC( (short)VisSectionIndices.visSectionObject, (short)VisRowIndices.visRowLine, (short)VisCellIndices.visLineBeginArrow).Formula;

String endArrow = shape_V.get_CellsSRC(
(short)VisSectionIndices.visSectionObject,
(short)VisRowIndices.visRowLine,
(short)VisCellIndices.visLineEndArrow).Formula;

}

C# visio SDK has examples for VBA and other.
 

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