<?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 Feature Layer Search and Create Feature Layer from Selected Features in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/feature-layer-search-and-create-feature-layer-from/m-p/722098#M55891</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am rather new to arcpy, however I am moving my AddIns from VB.net over to python.&amp;nbsp; I am trying to search for a feature layer(s) and if found check to see if they have a selection.&amp;nbsp; If so create a feature layer from that selection. If not do nothing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have attached a portion of the code I'm trying to use.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;Brad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Mar 2015 16:46:15 GMT</pubDate>
    <dc:creator>BradGagliano</dc:creator>
    <dc:date>2015-03-11T16:46:15Z</dc:date>
    <item>
      <title>Feature Layer Search and Create Feature Layer from Selected Features</title>
      <link>https://community.esri.com/t5/python-questions/feature-layer-search-and-create-feature-layer-from/m-p/722098#M55891</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am rather new to arcpy, however I am moving my AddIns from VB.net over to python.&amp;nbsp; I am trying to search for a feature layer(s) and if found check to see if they have a selection.&amp;nbsp; If so create a feature layer from that selection. If not do nothing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have attached a portion of the code I'm trying to use.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;Brad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Mar 2015 16:46:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/feature-layer-search-and-create-feature-layer-from/m-p/722098#M55891</guid>
      <dc:creator>BradGagliano</dc:creator>
      <dc:date>2015-03-11T16:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: Feature Layer Search and Create Feature Layer from Selected Features</title>
      <link>https://community.esri.com/t5/python-questions/feature-layer-search-and-create-feature-layer-from/m-p/722099#M55892</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It seems I have answered my own question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had&lt;/P&gt;&lt;P&gt;if lyr == "CRASHES1997":&lt;/P&gt;&lt;P&gt;I should have had&lt;/P&gt;&lt;P&gt;if lyr.name == "CRASHES1997":&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Mar 2015 19:02:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/feature-layer-search-and-create-feature-layer-from/m-p/722099#M55892</guid>
      <dc:creator>BradGagliano</dc:creator>
      <dc:date>2015-03-11T19:02:18Z</dc:date>
    </item>
    <item>
      <title>Re: Feature Layer Search and Create Feature Layer from Selected Features</title>
      <link>https://community.esri.com/t5/python-questions/feature-layer-search-and-create-feature-layer-from/m-p/722100#M55893</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Assuming this is the snippet of code you're asking about?&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for lyr in arcpy.mapping.ListLayers(mxd, "CRASHES1999", df):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr == "CRASHES1999":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; desc = arcpy.Describe("CRASHES1999")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in_table = "CRASHES1999"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; field_names = "YEAR"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if desc.FIDSet:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.SearchCursor(in_table, field_names) as cursor:
&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;&amp;nbsp; for row in cursor:
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(in_table, "SelectedCrashes1999")
&amp;nbsp;&amp;nbsp;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "No Features Selected for CRASHES1999"

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del desc
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del in_table
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del field_names&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did you have a specific question or problem? Just guessing, but I see you're passing the field names for the search cursor as a string. According to &lt;A href="http://resources.arcgis.com/en/help/main/10.2/018w/018w00000011000000.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;the documentation&lt;/A&gt;, it needs to be a list or tuple. Try this instead:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;field_names = ["YEAR"]&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:53:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/feature-layer-search-and-create-feature-layer-from/m-p/722100#M55893</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-12-12T06:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: Feature Layer Search and Create Feature Layer from Selected Features</title>
      <link>https://community.esri.com/t5/python-questions/feature-layer-search-and-create-feature-layer-from/m-p/722101#M55894</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, this did seem to make it run smoother and quicker.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Mar 2015 10:55:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/feature-layer-search-and-create-feature-layer-from/m-p/722101#M55894</guid>
      <dc:creator>BradGagliano</dc:creator>
      <dc:date>2015-03-12T10:55:46Z</dc:date>
    </item>
  </channel>
</rss>

