This sample will reverse the direction of, or flip, the selected displacement links in ArcMap. You do not have to be in an edit session to perform the flip.
How to use
- Copy and paste this code into ArcMap VBA.
- Select the displacement links you wish to flip.
- Run the macro FlipLinks from the tools -> macros menu.
Public Sub FlipLinks()
'Flip selected displacement links
Dim pMxDoc As IMxDocument
Dim pGraConSel As IGraphicsContainerSelect
Dim pElementEnum As IEnumElement
Dim pElement As IElement
Dim pDLink As IDisplacementLinkElement
Dim pPolyLine As IPolyline
'Get the map and graphics container (Selected)
Set pMxDoc = ThisDocument
Set pGraConSel = pMxDoc.FocusMap
'Get enum of graphic elements
Set pElementEnum = pGraConSel.SelectedElements
pElementEnum.Reset
'loop through enum and look for displacement links
Set pElement = pElementEnum.Next
Do Until pElement Is Nothing
If TypeOf pElement Is IDisplacementLinkElement Then
'flip the link via polyline geometry
Set pPolyLine = pElement.Geometry
pPolyLine.ReverseOrientation
pElement.Geometry = pPolyLine
End If
Set pElement = pElementEnum.Next
Loop
pMxDoc.ActiveView.Refresh
End Sub