How to reset link IDs


Each time you create displacement links within an ArcMap project the link id is incremented by 1. If you are creating numerous links or importing links from a text file you may need to reset the id of existing links for reporting or recording purposes. The link id has no effect on a spatial adjustment.
This sample resets the id's of all displacement links within the project. The base id is hardcoded but could be presented to the user in an input form.

How to use

  1. Copy and paste this code into ArcMap VBA.
  2. Run the macro ResetLinkID from the tools -> macros menu.
[VBA]
Public Sub ResetLinkID()
    
    Const baseid As Integer = 1
    
    Dim pMxDoc As IMxDocument
    Dim pGraCon As IGraphicsContainer
    Dim pElement As IElement
    Dim pDLink As IDisplacementLinkElement
    Dim currentid As Integer
    
    'Get the map and graphics container
    Set pMxDoc = ThisDocument
    Set pGraCon = pMxDoc.FocusMap
    pGraCon.Reset
    
    currentid = baseid
    
    'Loop through graphics container and look for displacement links
    Set pElement = pGraCon.Next
    Do Until pElement Is Nothing
        If TypeOf pElement Is IDisplacementLinkElement Then
            
            'Get the displacement link and reset the ID
            Set pDLink = pElement
            pDLink.ID = currentid
            currentid = currentid + 1
            
        End If
        Set pElement = pGraCon.Next
    Loop
    
    pMxDoc.ActiveView.Refresh
    
End Sub