<?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: arcpy function to test for selected features in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-function-to-test-for-selected-features/m-p/681090#M52771</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You could try GetCount.&amp;nbsp; This was at 9.3.1 with arcgisscripting&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;result = gp.GetCount(ParcelInfo) #Total Anno Count
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.SelectLayerByAttribute_management(SpecAnno, SubSel, AC[0])
&amp;nbsp;&amp;nbsp;&amp;nbsp; result = gp.GetCount(ACParcelInfo)
&amp;nbsp;&amp;nbsp;&amp;nbsp; getSel = result.GetOutput(0)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if getSel &amp;gt;= 1:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do something
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif getSel == 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do something else&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 04:40:35 GMT</pubDate>
    <dc:creator>TedCronin</dc:creator>
    <dc:date>2021-12-12T04:40:35Z</dc:date>
    <item>
      <title>arcpy function to test for selected features</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-function-to-test-for-selected-features/m-p/681089#M52770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello! &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am searching for a function that would return a Boolean value if there are selected features in an mxd.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I know you can use arcpy.SelectLayerByAttribute_management(Layer, "CLEAR_SELECTION") to clear selections for a layer but I don't want to clear just test.&amp;nbsp; The maps were exported to pdf and may have the selected features showing on the pdf docs.&amp;nbsp; I need a function to&amp;nbsp; test which mxd's have selected features and I've got about 1600 maps.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Josh&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 May 2011 15:15:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-function-to-test-for-selected-features/m-p/681089#M52770</guid>
      <dc:creator>JoshuaJohnson1</dc:creator>
      <dc:date>2011-05-18T15:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy function to test for selected features</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-function-to-test-for-selected-features/m-p/681090#M52771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You could try GetCount.&amp;nbsp; This was at 9.3.1 with arcgisscripting&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;result = gp.GetCount(ParcelInfo) #Total Anno Count
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.SelectLayerByAttribute_management(SpecAnno, SubSel, AC[0])
&amp;nbsp;&amp;nbsp;&amp;nbsp; result = gp.GetCount(ACParcelInfo)
&amp;nbsp;&amp;nbsp;&amp;nbsp; getSel = result.GetOutput(0)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if getSel &amp;gt;= 1:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do something
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif getSel == 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do something else&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:40:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-function-to-test-for-selected-features/m-p/681090#M52771</guid>
      <dc:creator>TedCronin</dc:creator>
      <dc:date>2021-12-12T04:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy function to test for selected features</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-function-to-test-for-selected-features/m-p/681091#M52772</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Two methods I use (v9.3 code BTW, but easy to convert to arcpy):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For actual selections (must be a selection made by SelectByAttributes or SelectByLoactions and not a definition query):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;selectionCount = len(gp.describe(lyr).fidset.split(";"))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But for layers that might have a differenet feature count than the actual feature class they are based off (via a definition query or some SQL used by the MakeFeatuerLayer tool):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;selectionCount = int(gp.GetCount_management(gp.describe(lyr).catalogpath).getoutput(0)) - int(gp.GetCount_management(lyr).getoutput(0))&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 May 2011 15:39:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-function-to-test-for-selected-features/m-p/681091#M52772</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2011-05-18T15:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy function to test for selected features</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-function-to-test-for-selected-features/m-p/681092#M52773</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks to you both.&amp;nbsp; Does arcgisscripting even work with v10.0?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Josh&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 May 2011 22:02:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-function-to-test-for-selected-features/m-p/681092#M52773</guid>
      <dc:creator>JoshuaJohnson1</dc:creator>
      <dc:date>2011-05-18T22:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy function to test for selected features</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-function-to-test-for-selected-features/m-p/681093#M52774</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Does arcgisscripting even work with v10.0?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It does if you use the default version of Python that is auto-installed with v10 (and you don't try to monkey with or upgrade it).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Although I think(?) in this case all you have to do is change "gp" to "arcpy":&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;selectionCount = len(arcpy.describe(lyr).fidset.split(";"))
#or
selectionCount = int(arcpy.GetCount_management(gp.describe(lyr).catalogpath).getoutput(0)) - int(arcpy.GetCount_management(lyr).getoutput(0)) &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:40:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-function-to-test-for-selected-features/m-p/681093#M52774</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-12T04:40:37Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy function to test for selected features</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-function-to-test-for-selected-features/m-p/681094#M52775</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;arcgisscripting.create(10.0).&amp;nbsp; You can migrate when you want to, basically at 10, which is pretty cool.&amp;nbsp; I have lots of pre 10 scripts in production, and just port when I have the time or need arcpy.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 May 2011 01:07:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-function-to-test-for-selected-features/m-p/681094#M52775</guid>
      <dc:creator>TedCronin</dc:creator>
      <dc:date>2011-05-19T01:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy function to test for selected features</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-function-to-test-for-selected-features/m-p/681095#M52776</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi everyone, I've got a similar situation... I've tried the above mentioned feature selection detection scripts but they do not work on my ArcMap 10.2. Or maybe I'm not puting them in right?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've got a button that when pressed performs two field calculations - one on a polygon layer then another on a arc layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;However I want to put in a failsafe so it will not do anything if nothing is selected since this morning I accidentally had a polygon selected and there was no arc selected so it field calc'ed the entire Kerb_Channel arc feature class with one value!!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Basically they're polygon traffic islands with arc kerb lines around them, however the prefab traffic islands must not have a kerb line because there is no seperate kerb. I've used the ArcGIS AddIn Assistant to make the button with this Arcpy script which I copied and pasted from an exported to Python Model Builder model:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import pythonaddins&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Local variables:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Traffic_Islands = "Island+Kerb Topology\\Traffic_Islands"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Kerb_Channel = "Island+Kerb Topology\\Kerb_Channel"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;class ButtonClass1(object):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; """Implementation for SetKerbType_addin.button (Button)"""&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; def __init__(self):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.enabled = True&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.checked = False&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; def onClick(self):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Some kind of selection detection code here for the Kerb_Channel layer since a polygon will always be selected&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(Traffic_Islands, "KERB_TYPE", "\"SM3\"", "VB", "")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(Kerb_Channel, "KERBTYPE", "\"SM3\"", "VB", "")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, is there a PDF or site somewhere that has the Arcpy procedures and functions and what they do etc like there is for normal Python? I've googled it and I can't find anything with a list of Arcpy procedures/functions with what they do and how to use them.&amp;nbsp; Something like SharpDev's inline help would be awesome.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Gregg&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Nov 2013 03:55:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-function-to-test-for-selected-features/m-p/681095#M52776</guid>
      <dc:creator>GreggPitts</dc:creator>
      <dc:date>2013-11-01T03:55:16Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy function to test for selected features</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-function-to-test-for-selected-features/m-p/681096#M52777</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;How about something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Traffic_Islands = "Island+Kerb Topology\\Traffic_Islands"
Kerb_Channel = "Island+Kerb Topology\\Kerb_Channel"
class ButtonClass1(object):
&amp;nbsp;&amp;nbsp; """Implementation for SetKerbType_addin.button (Button)"""
&amp;nbsp;&amp;nbsp; def __init__(self):
&amp;nbsp;&amp;nbsp; self.enabled = True
&amp;nbsp;&amp;nbsp; self.checked = False
&amp;nbsp;&amp;nbsp; def onClick(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(arcpy.Describe(Traffic_Islands).fidset.split(";")) &amp;gt; 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(Traffic_Islands, "KERB_TYPE", "\"SM3\"", "VB", "")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #tell the user they are doing something wrong
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(arcpy.Describe(Kerb_Channel).fidset.split(";")) &amp;gt; 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(Kerb_Channel, "KERBTYPE", "\"SM3\"", "VB", "")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #tell the user they are doing something wrong&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:40:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-function-to-test-for-selected-features/m-p/681096#M52777</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-12T04:40:40Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy function to test for selected features</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-function-to-test-for-selected-features/m-p/681097#M52778</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Okay your right... a better way:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;selectedCount = len([int(fid) for fid in arcpy.Describe(layerName).fidset.split(";") if fid != ''])&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Nov 2013 21:05:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-function-to-test-for-selected-features/m-p/681097#M52778</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2013-11-18T21:05:28Z</dc:date>
    </item>
  </channel>
</rss>

