0

What is the Process to find the inverse of selected data from featureclass using vb.net arcobject?

3
  • 1
    Do you mean the remaining data that isn't selected?
    – pvdev
    Jun 18, 2014 at 10:23
  • 1
    In most GIS you have an option to invert the current selection. Without more information it's hard to be more specific
    – Damien
    Jun 18, 2014 at 12:57
  • yes , like i got all the points within the polygon now if i will inverse the selection then there will be point which are not inside the polygon .So , i want to know how we will get this using arcobject .
    – sudoku
    Jun 19, 2014 at 6:21

2 Answers 2

2

The following VBA code shows you how to inverse the current selection on a layer, you would then get a SelectionSet on it to step through the new selection.

Public Sub InverseSelection()
    ' Get Document
    Dim pMXdocument As IMxDocument
    Set pMXdocument = ThisDocument

    ' Get Map
    Dim pMap As IMap
    Set pMap = pMXdocument.FocusMap

    ' Get first layer in TOC
    Dim pLayer As ILayer
    Set pLayer = pMap.Layer(0)

    ' QI into IFeatureLayer
    Dim pFeatureLayer As IFeatureLayer
    Set pFeatureLayer = pLayer

    ' Get feature selection
    Dim pFeatureSelection As IFeatureSelection
    Set pFeatureSelection = pFeatureLayer

    ' Inverse the selection
    pFeatureSelection.SelectFeatures Nothing, esriSelectionResultXOR, False
    pMXdocument.ActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing
End Sub 
0

I don't think it's possible to call the switch selection option that is available in ArcGIS using ArcObjects.

A workaround might be to use ISelectionSet.Combine

Get a selection set of the records you want using iFeatureClass.Select, then get a second selection set of all records in the featureclass using iFeatureClass.Select (by passing 'nothing' as the query filter). Use the Combine method on this second selection set using the ESRISetOperation "difference" and that should give you all of the records which are not part of the first selection set.

Not the answer you're looking for? Browse other questions tagged or ask your own question.