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


Get Active Analysis Layer Snippet (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference

Get Active Analysis Layer Snippet

Gets the active analysis layer from the Network Analyst extension.

[C#]
///<summary>Gets the active analysis layer from the Network Analyst extension.</summary>
/// 
///<param name="networkAnalystExtension">An INetworkAnalystExtension interface.</param>
/// 
///<returns>An INALayer3 interface.</returns>
/// 
///<remarks></remarks>
public ESRI.ArcGIS.NetworkAnalyst.INALayer3 GetActiveAnalysisLayer(ESRI.ArcGIS.NetworkAnalystUI.INetworkAnalystExtension networkAnalystExtension)
{

  ESRI.ArcGIS.NetworkAnalystUI.INAWindow naWindow=networkAnalystExtension.NAWindow;
  ESRI.ArcGIS.NetworkAnalyst.INALayer naLayer=naWindow.ActiveAnalysis;
  ESRI.ArcGIS.NetworkAnalyst.INALayer3 naLayer3=naLayer as ESRI.ArcGIS.NetworkAnalyst.INALayer3; // Dynamic Cast

  return naLayer3;

}
[Visual Basic .NET]
'''<summary>Gets the active analysis layer from the Network Analyst extension.</summary>
''' 
'''<param name="networkAnalystExtension">An INetworkAnalystExtension interface.</param>
''' 
'''<returns>An INALayer3 interface.</returns>
''' 
'''<remarks></remarks>
Public Function GetActiveAnalysisLayer(ByVal networkAnalystExtension As ESRI.ArcGIS.NetworkAnalystUI.INetworkAnalystExtension) As ESRI.ArcGIS.NetworkAnalyst.INALayer3

  Dim naWindow As ESRI.ArcGIS.NetworkAnalystUI.INAWindow=networkAnalystExtension.NAWindow
  Dim naLayer As ESRI.ArcGIS.NetworkAnalyst.INALayer=naWindow.ActiveAnalysis
  Dim naLayer3 As ESRI.ArcGIS.NetworkAnalyst.INALayer3=TryCast(naLayer, ESRI.ArcGIS.NetworkAnalyst.INALayer3) ' Dynamic Cast

  Return naLayer3

End Function

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