[Visual Basic 6.0]'This example shows how to find a sub-layer in the NALayer by the name of the NAClass and how to reposition the sublayers within a NALayer. Public Sub MoveODPathsToTheTop() Dim pMxDoc As IMxDocument Dim pNALayer As INALayer Dim pNAContext As INAContext Dim pDataset As IDataset Set pMxDoc = ThisDocument 'Make sure you have a layer selected If pMxDoc.SelectedLayer Is Nothing Then MsgBox "You must select an ODCostMatrix Layer" Exit Sub End If 'Make sure the selected layer is an ODCostMatrix Layer If Not TypeOf pMxDoc.SelectedLayer Is INALayer Then MsgBox "You must select an ODCostMatrix Layer" Exit Sub End If Set pNALayer = pMxDoc.SelectedLayer 'Get the ODPaths Layer Dim pODPathsLayer As ILayer Set pODPathsLayer = pNALayer.LayerByNAClassName("ODLines") If pODPathsLayer Is Nothing Then MsgBox "You must select an ODCostMatrix Layer" Exit Sub End If 'Loop through and get a collection of all the layers Dim pCompositeLayer As ICompositeLayer2 Set pCompositeLayer = pNALayer Dim i As Long Dim count As Long count = pCompositeLayer.count ReDim pLayers(0 To count - 1) As ILayer For i = 0 To count - 1 Set pLayers(i) = pCompositeLayer.Layer(i) Next i 'remove all the layers pNALayer.Clear 'Add the ODPaths Layer to the top pNALayer.Add pODPathsLayer For i = 0 To count - 1 If Not pLayers(i) Is pODPathsLayer Then pNALayer.Add pLayers(i) End If Next i pMxDoc.UpdateContents End Sub
[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.