<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Clear Selection with Arcpy in Mapping Questions</title>
    <link>https://community.esri.com/t5/mapping-questions/clear-selection-with-arcpy/m-p/1180255#M8462</link>
    <description>&lt;P&gt;Could I use this code to find and unselected selected features that have a value (not null) in a certain attribute? How would I modify it to do that? Thanks&lt;BR /&gt;&lt;BR /&gt;Doug&lt;/P&gt;</description>
    <pubDate>Mon, 06 Jun 2022 15:50:29 GMT</pubDate>
    <dc:creator>DougWolfinger2</dc:creator>
    <dc:date>2022-06-06T15:50:29Z</dc:date>
    <item>
      <title>Clear Selection with Arcpy</title>
      <link>https://community.esri.com/t5/mapping-questions/clear-selection-with-arcpy/m-p/162552#M1802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: farsterbj&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In my script ToolValidator class, I am using arcpy.SelectLayerByLocation_management to clear selected features in all of my data frames.&amp;nbsp; Events in my ToolValidator will not work properly if there is a selection on certain layers, thus the need to clear selection.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I run the tool, the routine successfully clears selected features in all data frames, but it is ugly!&amp;nbsp; For each layer that I clear selection on, a geoprocessing result box pops up and the map is locked up until all the 'geoprocessing' operations are complete.&amp;nbsp; This happens anytime a user alters parameters in the tool dialog.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anyone know how to clear selected features in a data frame in a cleaner fashion; either by executing arcpy.SelectLayerByLocation_management in the background or by simply leveraging the functionality of the 'Clear Selected Features' button on the 'Tools' toolbar?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's a subset of my code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Clear selections on the MAPPING_EXTENTS and TOWNS layers in each data frame
# This code could be modified to clear selections on every layer in every data frame
&amp;nbsp;&amp;nbsp;&amp;nbsp; dfCount = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; for df in arcpy.mapping.ListDataFrames(mxd):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dfCount += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; for dfIndex in range(dfCount):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df = arcpy.mapping.ListDataFrames(mxd)[dfIndex]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clearLyrs = ["MAPPING_EXTENTS", "TOWNS"]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for clearLyr in clearLyrs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr = arcpy.mapping.ListLayers(mxd, clearLyr, df)[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(lyr, "CLEAR_SELECTION")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Brad&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:32:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/clear-selection-with-arcpy/m-p/162552#M1802</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T08:32:24Z</dc:date>
    </item>
    <item>
      <title>Re: Clear Selection with Arcpy</title>
      <link>https://community.esri.com/t5/mapping-questions/clear-selection-with-arcpy/m-p/162553#M1803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: jbarrette&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello Brad,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your clear selection code is very similar to code that I use in scripts and I've never experienced these popups before.&amp;nbsp; I tried to reproduce this using your code logic and was not able to generate popups.&amp;nbsp; It worked as expected.&amp;nbsp; I assume this is all runing in a validation script. I tried running the script tool from ArcMap and ArcCatalog.&amp;nbsp; I used "CURRENT" and a path to an MXD.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could you please provide me more context for further testing.&amp;nbsp; If possible could you send me your script tool?&amp;nbsp; Please email &lt;/SPAN&gt;&lt;A href="mailto:jbarrette@esri.com"&gt;jbarrette@esri.com&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Nov 2010 13:39:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/clear-selection-with-arcpy/m-p/162553#M1803</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2010-11-02T13:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: Clear Selection with Arcpy</title>
      <link>https://community.esri.com/t5/mapping-questions/clear-selection-with-arcpy/m-p/162554#M1804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Brad and/or Jeff.&amp;nbsp; Was there any solution to this?&amp;nbsp; I've actually tried to do the exact same thing I agree...it's pretty ugly.&amp;nbsp; It takes about 5 minutes to run through each layer, run the Select Layer By Attribute tool, clear the selection and provide a pop-up result window.&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the code I'm using in the Validation code of my script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument(r"C:\Temp\test.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df = arcpy.mapping.ListDataFrames(mxd)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for lyr in arcpy.mapping.ListLayers(mxd):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print lyr.name&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(lyr, "CLEAR_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for aTable in arcpy.mapping.ListTableViews(mxd):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print aTable.name&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(aTable, "CLEAR_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be appreciated!&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Amanda&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Nov 2011 16:43:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/clear-selection-with-arcpy/m-p/162554#M1804</guid>
      <dc:creator>AmandaS</dc:creator>
      <dc:date>2011-11-09T16:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: Clear Selection with Arcpy</title>
      <link>https://community.esri.com/t5/mapping-questions/clear-selection-with-arcpy/m-p/162555#M1805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Amanda,&lt;/P&gt;&lt;P&gt;You may have figured this out already. &lt;/P&gt;&lt;P&gt;In Geoprocessing options, change the notification time&amp;nbsp; (it's a bar) to 0, you'll not see the popup window any more, but you may not know your processing is done. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lang &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Mar 2015 21:31:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/clear-selection-with-arcpy/m-p/162555#M1805</guid>
      <dc:creator>LangDeng</dc:creator>
      <dc:date>2015-03-19T21:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: Clear Selection with Arcpy</title>
      <link>https://community.esri.com/t5/mapping-questions/clear-selection-with-arcpy/m-p/1180255#M8462</link>
      <description>&lt;P&gt;Could I use this code to find and unselected selected features that have a value (not null) in a certain attribute? How would I modify it to do that? Thanks&lt;BR /&gt;&lt;BR /&gt;Doug&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 15:50:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/clear-selection-with-arcpy/m-p/1180255#M8462</guid>
      <dc:creator>DougWolfinger2</dc:creator>
      <dc:date>2022-06-06T15:50:29Z</dc:date>
    </item>
  </channel>
</rss>

