Connection Points

A

Ashok

Hi

I have serious problem to solve....

Of A shape placed, i need to add connection points
dynamically during the automation. Can Anyone help me in
creating new connection points dynamically

Any kind of help is appreciated.

Regards
Ashok Kumar
 
M

Markus Breugst

Hi Ashok,

I've written a small example macro for you. Hope it helps. The macro creates
two connection points: one at the top and one at the bottom of a shape named
"Sheet.1".

Best regards,
Markus

Public Sub CreateCP()
Dim myShape As Shape
Dim rowIndex As Integer
Dim myRow As Row
Dim myCell As Cell

' Get shape reference. Assumption: Shape name is "Sheet.1"
Set myShape = Visio.ActivePage.PageSheet.Shapes("Sheet.1")

' Create Connection Points Section (if it does not exist)
If (Not (myShape.SectionExists(Visio.visSectionConnectionPts, 1))) Then
myShape.AddSection (Visio.visSectionConnectionPts)
End If

' Add row for 1st connection point
rowIndex = myShape.AddRow(Visio.visSectionConnectionPts,
Visio.visRowConnectionPts, 0)
' Set X value of connection point
Set myCell = myShape.CellsSRC(Visio.visSectionConnectionPts,
Visio.visRowConnectionPts, 0)
myCell.Formula = "=Width/2"
' Set Y value of connection point
Set myCell = myShape.CellsSRC(Visio.visSectionConnectionPts,
Visio.visRowConnectionPts, 1)
myCell.Formula = "=0"
' Add row for 2nd connection point
rowIndex = myShape.AddRow(Visio.visSectionConnectionPts,
Visio.visRowConnectionPts + 1, 0)
' Set X value of connection point
Set myCell = myShape.CellsSRC(Visio.visSectionConnectionPts,
Visio.visRowConnectionPts + 1, 0)
myCell.Formula = "=Width/2"
' Set Y value of connection point
Set myCell = myShape.CellsSRC(Visio.visSectionConnectionPts,
Visio.visRowConnectionPts + 1, 1)
myCell.Formula = "=Height"
End Sub
 
A

Ashok

Hi Markus

It Worked fine in VB. I was not able to get the equivalent in C#. But i got an other alternative by using GlueToPos command.

Thanks a lot for your effort.

I have a very simple question to be asked. I could not access the Height and Width of the Shape. Could you help me in doing that?

Regards
Ashok
 
M

Markus Breugst

I have a very simple question to be asked. I could not access the Height
and Width of the Shape. Could you help me in doing that?

Yes. Here is an example in C#:

Getting the height value:
IVShape _vShape = ...;
double _height = _vShape.get_Cells( "Height" ).ResultIU;

ResultIU means that the result is given in Internal Units.

Setting the height value:
double _value = ...;
IVShape _vShape = ...;
_vShape.get_Cells( "Height" ).ResultIUForce = _value;

"Force" means that the value is set even if the height cell is protected via
a GUARD function.

If you want to provide a formula (means a String) instead of Internal Units,
just use FormulaForce instead of ResultIU:
string _value = ...;
IVShape _vShape = ...;
_vShape.get_Cells( "Height" ).FormulaForce = _value;

Best regards,
Markus
 

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