Thursday, April 22, 2010

ArcObjects: Clear Selected Features

The following is the VB code to quickly selected features in ArcMap with ArcObjects. This code will perform the same function as clicking the Clear Selected Features tool on the ArcMap interface.

There are two parts: the setup (Dim/Set instances), then clear the selection with a partial refresh followed by pMap.ClearSelection (in that order).  This example is a command button that will run the method after a Click event:

Private Sub cmdClear_Click()
    Dim pMxDocument As IMxDocument
   
Dim pMap As IMap
   
Dim pActiveView As IActiveView
    Set pMxDocument = ThisDocument
   
Set pMap = pMxDocument.FocusMap
   
Set pActiveView = pMap

    pActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing
    pMap.ClearSelection
End Sub

4 comments:

Justin said...

(I'm getting better at posting code)

Anonymous said...

Thanks for the code here Justin!

I see you may post about displaying geotagged photos in Arcmap...

Do you know how to link video "along a line segment" (when the video plays, a point moves along the path, as defined by the video geo-tag). The video would have to play outside of Arcmap of course.

Great work mate,

Cheers,
Tom
Ottawa, Canada

Justin said...

That would be a great visualization tool! I'm familiar with geotagged photos (lat/long/compass bearing), but not so much with geotagged video. Essentially it should be the same principle, though: a Silverlight / Flash player will be linked to an interactive map (Google Maps for instance) via the custom API, and each video frame will report to the map as a lat/long point or lat/long/direction arrow head. Very cool idea.

Justin said...

The Contour company makes a GPS enabled video camera that will do this. Looks rad, and I want three.