ArcGIS Developer Help  (EditorExt)    

INetworkAnalysisExtFlags Example

[Visual Basic 6.0]
'This example demonstrates how to use the properties and methods on the INetworkAnalysisExtFlags interface 
'g_pApplication is a variable of type IApplication holding a valid reference to the ArcMap application 
'SDE_CONNECTION_FILE is a string constant containing the path to an SDE connection file 
'FEATUREDATASET1_NAME ia a string constants containing a feature dataset name 
'GEOMETRICNETWORK1_NAME is a string constants containing a geometric network name 

Dim pNetworkAnalysisExtFlags As esriEditorExt.INetworkAnalysisExtFlags 
Dim pUID As New esriSystem.UID 
Dim pNetworkAnalysisExt As esriEditorExt.INetworkAnalysisExt 
Dim pWorkspaceFactory As esriGeoDatabase.IWorkspaceFactory 
Dim pFeatureWorkspace As esriGeoDatabase.IFeatureWorkspace 
Dim pNetworkCollection As esriGeoDatabase.INetworkCollection 
Dim pGeometricNetwork As esriGeoDatabase.IGeometricNetwork 
Dim pJunctionFlagDisplay As esriNetworkAnalysis.IJunctionFlagDisplay 
Dim pEdgeFlagDisplay As esriNetworkAnalysis.IEdgeFlagDisplay 
Dim lngFlagCount As Long 
Dim lngNetworkCount As Long 
Dim i As Long 

'obtain a reference to the interface by querying the application for the Utility Network Analysis extension 
pUID = "esriEditorExt.UtilityNetworkAnalysisExt" 
Set pNetworkAnalysisExtFlags = g_pApplication.FindExtensionByCLSID(pUID) 

'add a geometric network to the extension 
'create a new SDE workspace factory 
Set pWorkspaceFactory = New SdeWorkspaceFactory 
'create a feature workspace using the specified SDE connection file 
Set pFeatureWorkspace = pWorkspaceFactory.OpenFromFile(SDE_CONNECTION_FILE, 0) 
'get a reference to the INetworkCollection interface of the feature dataset 
Set pNetworkCollection = pFeatureWorkspace.OpenFeatureDataset(FEATUREDATASET1_NAME) 
'get a reference to the geometric network by specifying its name 
Set pGeometricNetwork = pNetworkCollection.GeometricNetworkByName(GEOMETRICNETWORK1_NAME) 
'add the network to the extension 
Set pNetworkAnalysisExt = pNetworkAnalysisExtFlags 
pNetworkAnalysisExt.AddNetwork pGeometricNetwork 

With pNetworkAnalysisExtFlags 

'add junction flags to the network using the AddJunctionFlag method 
For i = 0 To 9 
Set pJunctionFlagDisplay = New esriNetworkAnalysis.JunctionFlagDisplay 
.AddJunctionFlag pJunctionFlagDisplay 
Next i 

'get the number of junction flags on the current network using the JunctionFlagCount property 
lngFlagCount = .JunctionFlagCount 

'get a reference to the first junction flag on the network using the JunctionFlag property 
Set pJunctionFlagDisplay = .JunctionFlag(0) 

'add edge flags to the network using the AddEdgeFlag method 
For i = 0 To 9 
Set pEdgeFlagDisplay = New esriNetworkAnalysis.EdgeFlagDisplay 
.AddEdgeFlag pEdgeFlagDisplay 
Next i 

'get the number of edge flags on the current network using the EdgeFlagCount property 
lngFlagCount = .EdgeFlagCount 

'get a reference to the first edge flag on the network using the EdgeFlag property 
Set pEdgeFlagDisplay = .EdgeFlag(0) 

'clear all of the flags on the current network 
.ClearFlags 

End With 

'remove all of the networks from the extension using the DeleteNetwork method 
lngNetworkCount = pNetworkAnalysisExt.NetworkCount 
For i = 0 To lngNetworkCount - 1 
Set pGeometricNetwork = pNetworkAnalysisExt.CurrentNetwork 
pNetworkAnalysisExt.DeleteNetwork pGeometricNetwork 
Next i 

[Visual Basic .NET, C#, C++]
No example is available for Visual Basic .NET, C#, or C++. To view a Visual Basic 6.0 example, click the Language Filter button Language Filter in the upper-left corner of the page.