This document is archived and information here might be outdated.  Recommended version.


Clear Active Analysis Layer Snippet (ArcObjects .NET 10.6 SDK)
ArcObjects Library Reference

Clear Active Analysis Layer Snippet

Clears all input/output features previously stored in the currently active analysis layer.

[C#]
///<summary>Clears all input/output features previously stored in the currently active analysis layer.</summary>
///   
///<param name="naWindow">An INAWindow interface.</param>
///<param name="activeView">An IActiveView interface.</param>
///   
///<remarks></remarks>
public static void ClearActiveAnalysisLayer(ESRI.ArcGIS.NetworkAnalystUI.INAWindow naWindow, ESRI.ArcGIS.Carto.IActiveView activeView)
{
  ESRI.ArcGIS.NetworkAnalyst.INALayer naLayer=naWindow.ActiveAnalysis;
  ESRI.ArcGIS.NetworkAnalyst.INAContext naContext=naLayer.Context;
  ESRI.ArcGIS.NetworkAnalyst.INamedSet namedSet=naContext.NAClasses;

  naWindow.DelayEvents(null, true);
  naWindow.DelayWindowUpdates(true);

  ESRI.ArcGIS.NetworkAnalyst.INAClass naClass;
  for (System.Int32 i=0; i < namedSet.Count; i++)
  {
    System.Object theObject=namedSet.get_Item(i);
    naClass=theObject as ESRI.ArcGIS.NetworkAnalyst.INAClass;
    naClass.DeleteAllRows();
  }

  naWindow.DelayWindowUpdates(false);
  naWindow.DelayEvents(null, false);
  activeView.Refresh();
}
[Visual Basic .NET]
'''<summary>Clears all input/output features previously stored in the currently active analysis layer.</summary>
'''   
'''<param name="naWindow">An INAWindow interface.</param>
'''<param name="activeView">An IActiveView interface.</param>
'''   
'''<remarks></remarks>
Public Shared Sub ClearActiveAnalysisLayer(ByVal naWindow As ESRI.ArcGIS.NetworkAnalystUI.INAWindow, ByVal activeView As ESRI.ArcGIS.Carto.IActiveView)

  Dim naLayer As ESRI.ArcGIS.NetworkAnalyst.INALayer=naWindow.ActiveAnalysis
  Dim naContext As ESRI.ArcGIS.NetworkAnalyst.INAContext=naLayer.Context
  Dim namedSet As ESRI.ArcGIS.NetworkAnalyst.INamedSet=naContext.NAClasses

  naWindow.DelayEvents(Nothing, True)
  naWindow.DelayWindowUpdates(True)

  Dim naClass As ESRI.ArcGIS.NetworkAnalyst.INAClass
  Dim i As System.Int32=0

  For i=0 To namedSet.Count - 1

    Dim theObject As System.Object=namedSet.Item(i)
    naClass=CType(theObject, ESRI.ArcGIS.NetworkAnalyst.INAClass) ' Explicit Cast
    naClass.DeleteAllRows()

  Next

  naWindow.DelayWindowUpdates(False)
  naWindow.DelayEvents(Nothing, False)
  activeView.Refresh()

End Sub

Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.Carto
  • ESRI.ArcGIS.NetworkAnalyst
  • ESRI.ArcGIS.NetworkAnalystUI