How to densify polylines


This sample will densify selected polylines in an edit session.
This sample densifies selected polylines by inserting vertices every 10 percent of the polyline's length. This is useful in Spatial Adjustment Rubber Sheeting applications to align linear features where one feature may have less vertices than another.

How to use

  1. Select a polyline
  2. Paste the code into VBA and run the macro
[VBA]
Public Sub DensifyPolyLine()
    
    'Densify selected PolyLines in ArcMap
    'Inserts vertex at 10% length intervals
    
    Dim pApplication As IApplication
    Dim pEditor As IEditor
    Dim pEnumFeature As IEnumFeature
    Dim pFeature As IFeature
    Dim pPolyCurve As IPolycurve
    
    'Get the editor
    Set pApplication = Application
    Set pEditor = pApplication.FindExtensionByName("ESRI Object Editor")
    
    'If nothing selected the exit
    If pEditor.SelectionCount > 0 Then
        pEditor.StartOperation
    Else
        MsgBox "No Features selected", vbOKOnly, "Densify PolyLine"
        Exit Sub
    End If
    
    'Enumerate through each selected feature and densify
    Set pEnumFeature = pEditor.EditSelection
    pEnumFeature.Reset
    
    Set pFeature = pEnumFeature.Next
    Do Until pFeature Is Nothing
        Set pPolyCurve = pFeature.Shape
        pPolyCurve.Densify (pPolyCurve.Length / 10), 0
        pFeature.Store
        Set pFeature = pEnumFeature.Next
    Loop
    
    pEditor.StopOperation "Densify Polyline"
    
End Sub






Additional Requirements
  • An Edit Session.