ArcPy – Clearing Selected Features in ArcMap Using ArcPy

arcmappython

I would like to Clear Any Selected Features using python since it causes an error if I run my tool and the user has a recorded selected.

I need some thing here that runs ("CLEAR_SELECTION") first

rows = arcpy.SearchCursor(Table, " \"Name\" LIKE 'Albert%' ", "", "Name;")

Thoughts?

Best Answer

Here is the help document covering the function in question: Select Layer by Attribute (Data Management)

I think this is how you would implement it:

arcpy.SelectLayerByAttribute_management(Table, "CLEAR_SELECTION")
rows = arcpy.SearchCursor(Table, " \"Name\" LIKE 'Albert%' ", "", "Name;")

As an aside, there are a lot of helpful examples of how to use the various toolbox tools, and their python implementations on the ArcGIS Desktop Help Site in the Professional Library. Oftentimes a quick search there will yield an answer faster than on GIS.se

Hope this helps!

Related Question