i am using vb.net and arcgis 10.2.
i have 4 layers that i am creating a selection set from using select by attribute, however sometimes a layer or couple of them won't have any selected features. This is fine, but it creates a blank layer for the layers without selections in the toc. How can i search for the selection on a layer and then create the layer for only the selected features?
i have attached an example of my code.
Thanks in advance!
i was able to answer my own question after continuing to dig for the right direction.
here is what i came up with:
Public Sub CompliantFrmSelection()
Dim pMxDoc As IMxDocument = CType(My.ArcMap.Application.Document, IMxDocument)
Dim pMap As IMap = pMxDoc.FocusMap
Dim pEnumLayer As IEnumLayer = pMap.Layers
pEnumLayer.Reset()
Dim pLayer As ILayer = pEnumLayer.Next
Dim pFLayer As IFeatureLayer = Nothing
Do While Not pLayer Is Nothing
If TypeOf pLayer Is IFeatureLayer Then
pFLayer = TryCast(pLayer, IFeatureLayer)
Dim sel As IFeatureSelection
sel = TryCast(pFLayer, IFeatureSelection)
If sel.SelectionSet.Count > 0 Then
If pFLayer.Name = "Sidewalk" Then
CreateFeatureLayer("Sidewalk", "Sidewalk - Compliant")
End If
If pFLayer.Name = "Curb Ramp" Then
CreateFeatureLayer("Curb Ramp", "Curb Ramp - Compliant")
End If
If pFLayer.Name = "Crosswalk" Then
CreateFeatureLayer("Cross Walk", "Cross Walk - Compliant")
End If
If pFLayer.Name = "Audible Pedestrian Signal" Then
CreateFeatureLayer("Audible Pedestrian Signal", "Audible Pedestrian Signal - Compliant")
End If
End If
End If
pLayer = pEnumLayer.Next
Loop
End Sub
Public Sub NonCompliantFrmSelection()
Dim pMxDoc As IMxDocument = CType(My.ArcMap.Application.Document, IMxDocument)
Dim pMap As IMap = pMxDoc.FocusMap
Dim pEnumLayer As IEnumLayer = pMap.Layers
pEnumLayer.Reset()
Dim pLayer As ILayer = pEnumLayer.Next
Dim pFLayer As IFeatureLayer = Nothing
Do While Not pLayer Is Nothing
If TypeOf pLayer Is IFeatureLayer Then
pFLayer = TryCast(pLayer, IFeatureLayer)
Dim sel As IFeatureSelection
sel = TryCast(pFLayer, IFeatureSelection)
If sel.SelectionSet.Count > 0 Then
If pFLayer.Name = "Sidewalk" Then
CreateFeatureLayer("Sidewalk", "Sidewalk - NonCompliant")
End If
If pFLayer.Name = "Curb Ramp" Then
CreateFeatureLayer("Curb Ramp", "Curb Ramp - NonCompliant")
End If
If pFLayer.Name = "Crosswalk" Then
CreateFeatureLayer("Cross Walk", "Cross Walk - NonCompliant")
End If
If pFLayer.Name = "Audible Pedestrian Signal" Then
CreateFeatureLayer("Audible Pedestrian Signal", "Audible Pedestrian Signal - NonCompliant")
End If
End If
End If
pLayer = pEnumLayer.Next
Loop
End Sub