[Visual Basic 6.0]'This example demonstrates how to use the properties and methods on the INetworkAnalysisExtWeightFilter 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 pNetworkAnalysisExtWeightFilter As esriEditorExt.INetworkAnalysisExtWeightFilter 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 pNetSchema As esriGeoDatabase.INetSchema Dim pNetWeight As esriGeoDatabase.INetWeight Dim eWeightFilterType As esriNetworkAnalysis.esriWeightFilterType Dim strWeightName As String Dim lngWeightCount As Long Dim lngFilterRangeCount As Long Dim lngNetworkCount As Long Dim i As Long Dim blnApplyNotOperator As Boolean Dim varFromValue As Variant Dim varToValue As Variant 'obtain a reference to the interface by querying the application for the Utility Network Analysis extension pUID = "esriEditorExt.UtilityNetworkAnalysisExt" Set pNetworkAnalysisExtWeightFilter = 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 = pNetworkAnalysisExtWeightFilter pNetworkAnalysisExt.AddNetwork pGeometricNetwork 'QI for the INetSchema interface on the current network Set pNetSchema = pGeometricNetwork.Network With pNetworkAnalysisExtWeightFilter 'set the junction filter weight to use using the JunctionWeightFilterName property lngWeightCount = pNetSchema.WeightCount If lngWeightCount = 0 Then Exit Sub Set pNetWeight = pNetSchema.Weight(0) .JunctionWeightFilterName = pNetWeight.WeightName 'get the junction filter weight name using the JunctionWeightFilterName property strWeightName = .JunctionWeightFilterName 'set the to-from filter weight to use using the ToFromWeightFilterName property .ToFromEdgeWeightFilterName = pNetWeight.WeightName 'get the to-from filter weight name using the ToFromWeightFilterName property strWeightName = .ToFromEdgeWeightFilterName 'get the from-to filter weight name using the FromToWeightFilterName property .FromToEdgeWeightFilterName = pNetWeight.WeightName 'get the from-to filter weight name using the FromToWeightFilterName property strWeightName = .FromToEdgeWeightFilterName 'set the junction filter type using the SetFilterType method 'apply the Not operator to the junction weight filter blnApplyNotOperator = True .SetFilterType esriETJunction, esriWFRange, blnApplyNotOperator 'get the weight filter type using the GetFilterType method .GetFilterType esriETJunction, eWeightFilterType, blnApplyNotOperator 'add ranges for the junction weight filter varFromValue = 0 varToValue = 1 .AddFilterRange esriETJunction, varFromValue, varToValue varFromValue = 2 varToValue = 3 .AddFilterRange esriETJunction, varFromValue, varToValue 'get the number of junction weight filter ranges using the FilterRangeCount property lngFilterRangeCount = .FilterRangeCount(esriETJunction) 'get a junction filter range using the GetFilterRange property .GetFilterRange esriETJunction, 0, varFromValue, varToValue 'clear the junction filter ranges using the ClearRanges method .ClearRanges esriETJunction End With 'remove all of the networks from the extension 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
in the upper-left corner of the page.