<?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: Checking selection state on Featurelayer in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/checking-selection-state-on-featurelayer/m-p/188540#M14486</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Run a gp.Describe(layer) and you can get out the Layer properties FIDSet. This is a clumsy string of all the FIDs that are in the selection. But it enables you to get a list of which features are selected.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 15 May 2011 23:32:20 GMT</pubDate>
    <dc:creator>KimOllivier</dc:creator>
    <dc:date>2011-05-15T23:32:20Z</dc:date>
    <item>
      <title>Checking selection state on Featurelayer</title>
      <link>https://community.esri.com/t5/python-questions/checking-selection-state-on-featurelayer/m-p/188536#M14482</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I need to write script that changes some attributes for selected features.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there any way to chceck if featurelayer represent selection? Cause now when I'm using layer without any selection it changes attribiutes for all features and that not exactly what I want. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 May 2011 09:34:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/checking-selection-state-on-featurelayer/m-p/188536#M14482</guid>
      <dc:creator>ArkadiuszMatoszka</dc:creator>
      <dc:date>2011-05-13T09:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: Checking selection state on Featurelayer</title>
      <link>https://community.esri.com/t5/python-questions/checking-selection-state-on-featurelayer/m-p/188537#M14483</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can specify a query with the arcpy.UpdateCursor.&amp;nbsp; The update will only update records that are returned from this query.&amp;nbsp; Ex:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
fc = "parcels"

rows = arcpy.UpdateCursor(fc, "Area1 = 10")
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Area2 = 200
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:30:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/checking-selection-state-on-featurelayer/m-p/188537#M14483</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T09:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: Checking selection state on Featurelayer</title>
      <link>https://community.esri.com/t5/python-questions/checking-selection-state-on-featurelayer/m-p/188538#M14484</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The idea is, that user makes custom selection, not necessary by atributes or location, he may as well do it by simply clicking feature, so it doesn't solve the problem. Below is my code, maybe it helps somehow &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
DICT_VALUES = {'Tak': 'T',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Nie': 'F',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Bez zmian': None}

def updateDb(cur, field, value, teryts):
&amp;nbsp;&amp;nbsp;&amp;nbsp; update_string = "Update PLOTS set " + str(field) + " = '" + str(value) + "' where TERYT = :teryt"
&amp;nbsp;&amp;nbsp;&amp;nbsp; cur.prepare(update_string)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for teryt in teryts:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage('Setting ' + field + ' to ' + value + ' for plot ' + teryt)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur.execute(None, {'teryt': str(teryt)})
&amp;nbsp;&amp;nbsp;&amp;nbsp; con.commit()

import arcpy
import sys
try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; import cx_Oracle as cxo
except ImportError:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError('cx_Oracle module not found. Add module to sys.path or install module if necessary')
&amp;nbsp;&amp;nbsp;&amp;nbsp; sys.exit()

plots = sys.argv[1]
arcpy.AddMessage('Processing selection')
rows = arcpy.SearchCursor(plots)
teryt_nr = []
for plot in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if plot.TERYT:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; teryt_nr.append(plot.TERYT)
arcpy.AddMessage('Connecting to DB...')
con = cxo.connect('user/pass@db')
cur = con.cursor()
#
## POI
if DICT_VALUES[sys.argv[2]]:
&amp;nbsp;&amp;nbsp;&amp;nbsp; updateDb(cur, 'POI', DICT_VALUES[sys.argv[2]], teryt_nr)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I need is empty list "teryt_nr" in case where there is no selection on layer in arcmap &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:30:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/checking-selection-state-on-featurelayer/m-p/188538#M14484</guid>
      <dc:creator>ArkadiuszMatoszka</dc:creator>
      <dc:date>2021-12-11T09:30:58Z</dc:date>
    </item>
    <item>
      <title>Re: Checking selection state on Featurelayer</title>
      <link>https://community.esri.com/t5/python-questions/checking-selection-state-on-featurelayer/m-p/188539#M14485</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Use arcpy.GetCount_management() to check if the layer has a selection.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It will report back how many records are selected (if any).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 May 2011 18:37:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/checking-selection-state-on-featurelayer/m-p/188539#M14485</guid>
      <dc:creator>RDHarles</dc:creator>
      <dc:date>2011-05-13T18:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: Checking selection state on Featurelayer</title>
      <link>https://community.esri.com/t5/python-questions/checking-selection-state-on-featurelayer/m-p/188540#M14486</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Run a gp.Describe(layer) and you can get out the Layer properties FIDSet. This is a clumsy string of all the FIDs that are in the selection. But it enables you to get a list of which features are selected.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 15 May 2011 23:32:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/checking-selection-state-on-featurelayer/m-p/188540#M14486</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2011-05-15T23:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: Checking selection state on Featurelayer</title>
      <link>https://community.esri.com/t5/python-questions/checking-selection-state-on-featurelayer/m-p/188541#M14487</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Run a gp.Describe(layer) and you can get out the Layer properties FIDSet. This is a clumsy string of all the FIDs that are in the selection. But it enables you to get a list of which features are selected.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks, that solves my problem &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jun 2011 11:48:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/checking-selection-state-on-featurelayer/m-p/188541#M14487</guid>
      <dc:creator>ArkadiuszMatoszka</dc:creator>
      <dc:date>2011-06-08T11:48:44Z</dc:date>
    </item>
  </channel>
</rss>

