Reputation: 511
How do I add connection points to a shape?
I began this project adding regular rectangles to the page and using AutoConnect to connect them which worked perfectly because each connection created a new connection point on the rectangle. When I switched to rounded rectangles new connection points were not created and the connectors ended up overlapping each other.
I add rounded rectangles like this...
Application.ActiveWindow.Page.Drop Application.Documents.Item("BASIC_U.VSS").Masters.ItemU("Rounded rectangle"), 0, 0
I AutoConnect like this...
Dim vsoConnectorShape As Visio.Shape
Set vsoConnectorShape = Visio.ActivePage.Shapes("Dynamic connector")
vsoConnectorShape.CellsU("LineColor").Formula = "rgb(" + CStr(red) + ", " + CStr(green) + ", " + CStr(blue) + ")"
shp1.AutoConnect shp2, visAutoConnectDirNone, vsoConnectorShape
Upvotes: 1
Views: 3874
Reputation: 4327
You add connection points by adding rows to the shape's connection points section (visSectionConnectionPts). Code would look like:
Dim NewRow as Integer
NewRow = shp1.AddRow( visSectionConnectionPts , visRowLast, visTagDefault)
shp1.CellsSRC( visSectionConnectionPts, NewRow, visX).formula = "Width*0.5"
shp1.CellsSRC( visSectionConnectionPts, NewRow, visY).formula = "Height*0.5"
This code adds a new connection point to shp1, and sets the point in the center of the shape.
Upvotes: 4