<?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.mapping.AddLayer selection Funk (serious ESRI devs only) in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375261#M29671</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I appreciate your persistence and&amp;nbsp;patience &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp; You know how it goes probably, deep in a million problems and just want to get something done.&amp;nbsp; My bad for posting a sample with a typo, that was a noob mistake.&amp;nbsp; Happy to know others can bask in my misfortune now!&amp;nbsp; Just imagine how strange it was to pin this down when it's working for some and not others because some analyst add layers directly from catalog (sometimes) while others use the tool (sometimes) and this will only fail consistently after the first time with the tool, that happens to use THIS code. . . .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oh!&amp;nbsp; And, support did get back to me.&amp;nbsp; There is a bug and they want me to hack around it by allowing MakeFeatureLayer to add the layer, which is a total HACK and reasonably unacceptable in terms of having an API that claims to support an AddLayer function...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;More to come!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 06 Feb 2018 19:58:51 GMT</pubDate>
    <dc:creator>JosephArmbruster</dc:creator>
    <dc:date>2018-02-06T19:58:51Z</dc:date>
    <item>
      <title>Arcpy.mapping.AddLayer selection Funk (serious ESRI devs only)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375238#M29648</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hey everyone,&lt;/DIV&gt;&lt;DIV&gt;It's been ages since i've had to resort to the forums, but the time has come...&amp;nbsp; This is issue is occurring with:&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;10.3.0.4322&lt;/DIV&gt;&lt;DIV&gt;AND&lt;/DIV&gt;&lt;DIV&gt;10.5.1.7333&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;Problem: When a layer is added to the TOC, just as you see in the snippet below, feature selections will no longer be respected (or at least detected) by geoprocessing tools.&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;Description: The symptom of the problem is that obtaining the feature selection count of a geoprocessing layer in a python toolbox is inconsistent.&amp;nbsp; I've pinned it down to some issue with the way Arc (or ArcPy) is handling layers by Name.&amp;nbsp; Here are some snippets:&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;# make this an absolute path to some feature class in a geodatabase, you only need a minimum of two features to reproduce the issue, i'm using polygons.&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;path = #path to your polygon feature class with at least two features in it.&lt;/DIV&gt;&lt;DIV&gt;mxd = arcpy.mapping.MapDocument('CURRENT')&lt;BR /&gt;new_layer_name = os.path.basename(path)&lt;BR /&gt;arcpy.MakeFeatureLayer_management(path, new_layer_name)&lt;BR /&gt;new_layer = arcpy.mapping.Layer(new_layer_name)&lt;BR /&gt;arcpy.mapping.AddLayer(mxd.activeDataFrame, new_layer_name, 'BOTTOM')&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;del new_layer&lt;BR /&gt;del mxd&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;Use the code above in a geoprocessing tool to add a layer to the map.&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;Now, use the code below in a separate geoprocessing tool, to report the number of features selected in the map.&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;desc = arcpy.Describe(input_feature_class)&lt;BR /&gt;if desc.FIDSet:&lt;BR /&gt;&amp;nbsp;messages.addMessage('selection made')&lt;BR /&gt;&amp;nbsp;# you'll never get here with the layer above!!&lt;BR /&gt;else:&lt;BR /&gt;&amp;nbsp;messages.addMessage('no selection made')&lt;BR /&gt;&amp;nbsp;# you'll always get here even with a selection &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/DIV&gt;&lt;DIV&gt;# count will always be the entire feature class count, since no selection was registered&lt;BR /&gt;# to the layer....&lt;BR /&gt;feature_count =&amp;nbsp;int(arcpy.GetCount_management(input_feature_class).getOutput(0)&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;Notes:&lt;BR /&gt;- If you use the code above to add the feature class to the map.&amp;nbsp; Remove it from the toc (right click, remove) and add it using arc catalog (drag-drop), the feature selection will STILL not work.&amp;nbsp; Hence why I suggest it has something to do with the internal name resolution.&lt;/DIV&gt;&lt;DIV&gt;- If you start a new ArcMap instance, add the layer by drag-dropping it from Arc Catalog, the selection WILL work.&amp;nbsp; If you remove this layer and add it using the code above, all subsequent selections will NOT be respected.&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;I look forward to hearing from ESRI support.&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;Let me know if you have any questions,&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;Joseph Armbruster&lt;/DIV&gt;&lt;DIV&gt;0Lat Inc, Orlando Florida.&lt;/DIV&gt;&lt;DIV&gt;&lt;A href="mailto:joseph.armbruster@0lat.com"&gt;joseph.armbruster@0lat.com&lt;/A&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Feb 2018 19:23:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375238#M29648</guid>
      <dc:creator>JosephArmbruster</dc:creator>
      <dc:date>2018-02-05T19:23:20Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy.mapping.AddLayer selection Funk (serious ESRI devs only)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375239#M29649</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Joseph, welcome to the Geonet Community forums.&amp;nbsp; First, don't get discouraged, but you should move this to the &lt;A href="https://community.esri.com/community/developers/gis-developers/python?sr=search&amp;amp;searchId=83795ee7-e01d-4395-9caa-aa12c1990bab&amp;amp;searchIndex=0"&gt;https://community.esri.com/community/developers/gis-developers/python?sr=search&amp;amp;searchId=83795ee7-e01d-4395-9caa-aa12c1990bab&amp;amp;searchIndex=0&lt;/A&gt;‌ , since the ArcGIS API for Python is actually a newer product, mainly used for administration portals and for doing some analysis, simple mapping etc. outside of ArcMap/Catalog/Pro.&amp;nbsp; You can move it using the pulldown under Actions in the upper right corner.&amp;nbsp; I would have done this for you, but I don't have those rights in this space.&amp;nbsp; By adding the @ and space name it actually gets tagged.&amp;nbsp; I'll also add&amp;nbsp;&lt;A href="https://community.esri.com/community/gis/mapping?sr=search&amp;amp;searchId=b9b071a9-f5ac-4fac-92ae-c17ef9679487&amp;amp;searchIndex=4"&gt;https://community.esri.com/community/gis/mapping?sr=search&amp;amp;searchId=b9b071a9-f5ac-4fac-92ae-c17ef9679487&amp;amp;searchIndex=4&lt;/A&gt;‌&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, always good to post code using one of the options &lt;A href="https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting?sr=search&amp;amp;searchId=1753a87a-9033-4500-afb8-f4155c08ef32&amp;amp;searchIndex=4"&gt;/blogs/dan_patterson/2016/08/14/script-formatting?sr=search&amp;amp;searchId=1753a87a-9033-4500-afb8-f4155c08ef32&amp;amp;searchIndex=4&lt;/A&gt;‌&amp;nbsp; That way, the pesky spaces etc of python don't cause issues and there are line numbers to help with feedback.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, tech support doesn't necessarily follow the forums.&amp;nbsp; It will be other users (and yes, their are serious developers that are active in the forums).&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Again, don't get discouraged on using the forums.&amp;nbsp; Very active these days.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Feb 2018 20:29:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375239#M29649</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2018-02-05T20:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy.mapping.AddLayer selection Funk (serious ESRI devs only)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375240#M29650</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I haven't had a chance to test the code yet, but on first glance the following two lines caught my eye:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;desc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Describe&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;input_feature_class&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; desc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;FIDSet&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Since feature classes don't support FIDSet, feature layers do, the code above should generate an AttributeError if passed a feature class.&amp;nbsp; Are you seeing an AttributeError or are you passing it a feature layer?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:21:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375240#M29650</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-11T17:21:14Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy.mapping.AddLayer selection Funk (serious ESRI devs only)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375241#M29651</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Joshua, the problem is not as trivial as an AttributeError, hence why I added the&amp;nbsp;'serious ESRI devs only &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For clarification, the parameter type is a GPFeatureLayer but I access the parameter valueAsText and pass it into Describe.&amp;nbsp; Which is the correct ArcPythonic way of doing this.&amp;nbsp; FIDSet is a valid attribute in my test case.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Feb 2018 00:12:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375241#M29651</guid>
      <dc:creator>JosephArmbruster</dc:creator>
      <dc:date>2018-02-06T00:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy.mapping.AddLayer selection Funk (serious ESRI devs only)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375242#M29652</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like you are trying to get the count on the feature class, not what is loaded in the mxd document.&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;feature_count &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; int&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetCount_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;input_feature_class&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;getOutput&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is working for a layer loaded in the TOC:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;mxd &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapDocument&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'CURRENT'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
df &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListDataFrames&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
lyr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListLayers&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"SomeLayerInTOC"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; df&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
desc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Describe&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lyr&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
feature_count &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; desc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;FIDSet
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Number of selected features: {}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;len&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;feature_count&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;";"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:21:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375242#M29652</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-11T17:21:16Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy.mapping.AddLayer selection Funk (serious ESRI devs only)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375243#M29653</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have given it a shot and noticed a few things, but did manage to get it to work (although I'm using 10.6). What I did was:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an mxd open with a layer in it:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/395888_pastedImage_1.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I ran this code in the Python window of my ArcMap session:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; os
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;overwriteOutput &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token boolean"&gt;True&lt;/SPAN&gt;

path &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'C:\GeoNet\Selection\test.gdb\myLines'&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;#path to your polygon feature class with at least two features in it.&lt;/SPAN&gt;
mxd &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapDocument&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'CURRENT'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
new_layer_name &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;basename&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MakeFeatureLayer_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; new_layer_name&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# this already adds the layer to the data frame&lt;/SPAN&gt;
move_layer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListLayers&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; new_layer_name&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; mxd&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;activeDataFrame&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
ref_layer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListLayers&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; mxd&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;activeDataFrame&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MoveLayer&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;activeDataFrame&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ref_layer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; move_layer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"AFTER"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;del&lt;/SPAN&gt; move_layer
&lt;SPAN class="keyword token"&gt;del&lt;/SPAN&gt; ref_layer
&lt;SPAN class="keyword token"&gt;del&lt;/SPAN&gt; mxd&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Notice that there are a few difference with the code you provided:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I have added the overwriteOutput = True on line 3 since the new_layer_name will already exist after the first run and throw an error&lt;/LI&gt;&lt;LI&gt;on line 8, when you create a feature layer, it is already added to ArcMap (at the top, which you don't want)&lt;/LI&gt;&lt;LI&gt;You have a line of code that not added the layer but the layer name, which was wrong&lt;/LI&gt;&lt;LI&gt;On line 9 I create a layer object from the layer added and on line 10 I&amp;nbsp;get a reference to the last layer in the TOC&lt;/LI&gt;&lt;LI&gt;On line 11 these layers are used to move the added layer to the bottom&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now we have the layer at he bottom of the TOC:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/395889_pastedImage_2.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Next step is to do something with the tool to investigate the selection.&amp;nbsp;I created a simple tool and added this script:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;main&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;# GPFeatureLayer&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; feature_layer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameter&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; desc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Describe&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;feature_layer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; fid_set &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; desc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;FIDSet
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; fid_set &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;''&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lst_fid &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lst_fid &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; fid_set&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;';'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; len&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lst_fid&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddMessage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'selection made: {}'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;len&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lst_fid&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddMessage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lst_fid&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddMessage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'no selection made: {}'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;len&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lst_fid&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddMessage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lst_fid&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; feature_count &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; int&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetCount_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;feature_layer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;getOutput&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddMessage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'feature count: {}'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;feature_count&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; __name__ &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'__main__'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; main&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It only has a single parameter (Feature Layer). When I run the tool the first time (no selection made yet) something interesting is happening:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-3 jive-image" src="https://community.esri.com/legacyfs/online/395890_pastedImage_3.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The added layer appears twice in the list. When I select the&amp;nbsp;first element it will run and yield this:&lt;/P&gt;&lt;P&gt;&lt;IMG class="jive-image image-4" src="https://community.esri.com/legacyfs/online/395891_pastedImage_4.png" style="width: 620px; height: 309px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which was to be expected since no selection was made.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can make a selection:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-6 jive-image" src="https://community.esri.com/legacyfs/online/395893_pastedImage_6.png" style="width: 620px; height: 335px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And run the tool again, and this time only a single myLines is in the list:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-5 jive-image" src="https://community.esri.com/legacyfs/online/395892_pastedImage_5.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It has a selection which is correctly detected both ways:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-7 jive-image" src="https://community.esri.com/legacyfs/online/395894_pastedImage_7.png" style="width: 620px; height: 309px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So apart from the fact that the layer appears twice in the list of feature layers, the tool seems to work and detect the selection.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:21:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375243#M29653</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T17:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy.mapping.AddLayer selection Funk (serious ESRI devs only)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375244#M29654</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to add the layer just like I did to experience the issue...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Feb 2018 17:00:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375244#M29654</guid>
      <dc:creator>JosephArmbruster</dc:creator>
      <dc:date>2018-02-06T17:00:41Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy.mapping.AddLayer selection Funk (serious ESRI devs only)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375245#M29655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So, a few things here..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. "on line 8, when you create a feature layer, it is already added to ArcMap (at the top, which you don't want)"&lt;/P&gt;&lt;P&gt;MakeFeatureLayer_management does not necessarily add the layer to a dataframe...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. "You have a line of code that not added the layer but the layer name, which was wrong"&lt;/P&gt;&lt;P&gt;It's not wrong, that's a valid use for MakeFeatureLayer_management... It creates a feature layer, which is not necessarily attached to a data frame... Oh, andI believe &amp;nbsp;the layer names passed to MakeFeatureLayer must be unique per-process.&amp;nbsp; Otherwise, not sure how you would delete it once it's no longer needed, unless you can obtain the generate layer as an output parameter...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2."So apart from the fact that the layer appears twice in the list of feature layers, the tool seems to work and detect the selection."&lt;/P&gt;&lt;P&gt;That's a reasonably unacceptable workaround for an obvious software&amp;nbsp;problem&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Feb 2018 17:04:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375245#M29655</guid>
      <dc:creator>JosephArmbruster</dc:creator>
      <dc:date>2018-02-06T17:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy.mapping.AddLayer selection Funk (serious ESRI devs only)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375246#M29656</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if I add the layer using this code (which is exactly yours apart from line 1 pointing to my featureclass):&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;path &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'C:\GeoNet\Selection\test.gdb\myLines'&lt;/SPAN&gt;
mxd &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapDocument&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'CURRENT'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
new_layer_name &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;basename&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MakeFeatureLayer_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; new_layer_name&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
new_layer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Layer&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;new_layer_name&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddLayer&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;activeDataFrame&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; new_layer_name&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'BOTTOM'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;del&lt;/SPAN&gt; new_layer
&lt;SPAN class="keyword token"&gt;del&lt;/SPAN&gt; mxd&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This beautiful error is produced:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;Runtime error &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; File "&amp;lt;string&amp;gt;", line 6, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; File "c:\program files (x86)\arcgis\desktop10.6\arcpy\arcpy\utils.py", line 182, in fn_&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; return fn(*args, **kw)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; File "c:\program files (x86)\arcgis\desktop10.6\arcpy\arcpy\mapping.py", line 49, in AddLayer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; assert isinstance(add_layer, Layer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;AssertionError&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And the layer is added at the top:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/395920_pastedImage_2.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, your code is not working correctly...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:21:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375246#M29656</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T17:21:22Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy.mapping.AddLayer selection Funk (serious ESRI devs only)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375247#M29657</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;SPAN style="background-color: #ffffff;"&gt;MakeFeatureLayer_management does not necessarily add the layer to a dataframe...&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;It is the default setting in ArcMap.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/395924_pastedImage_1.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;If you will share the tool to other users, you will need to account for that behavior or check if it was added or not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;EM&gt;It's not wrong, that's a valid use for MakeFeatureLayer_management.&lt;/EM&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Make me wonder why an error is produced in my case when using your exact code...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;EM&gt;That's a reasonably unacceptable workaround for an obvious software problem &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/EM&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Contact support...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Feb 2018 17:25:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375247#M29657</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2018-02-06T17:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy.mapping.AddLayer selection Funk (serious ESRI devs only)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375248#M29658</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;SPAN style="background-color: #ffffff;"&gt;MakeFeatureLayer_management does not necessarily add the layer to a dataframe...&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;It is the default setting in ArcMap.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/395925_pastedImage_1.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;If you will share the tool to other users, you will need to account for that behavior or check if it was added or not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;EM&gt;It's not wrong, that's a valid use for MakeFeatureLayer_management.&lt;/EM&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Make me wonder why an error is produced in my case when using your exact code...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;EM&gt;That's a reasonably unacceptable workaround for an obvious software problem &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/EM&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Contact support...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Feb 2018 17:26:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375248#M29658</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2018-02-06T17:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy.mapping.AddLayer selection Funk (serious ESRI devs only)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375249#M29659</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Bah, copy/pasta typo... That line should be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy&lt;SPAN&gt;.&lt;/SPAN&gt;mapping&lt;SPAN&gt;.&lt;/SPAN&gt;AddLayer&lt;SPAN&gt;(&lt;/SPAN&gt;mxd&lt;SPAN&gt;.&lt;/SPAN&gt;activeDataFrame&lt;SPAN&gt;,&lt;/SPAN&gt; new_layer&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;'BOTTOM'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Feb 2018 17:27:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375249#M29659</guid>
      <dc:creator>JosephArmbruster</dc:creator>
      <dc:date>2018-02-06T17:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy.mapping.AddLayer selection Funk (serious ESRI devs only)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375250#M29660</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Never seen a "typo" occur from copy and past. Might want to report it to Microsoft.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Feb 2018 17:28:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375250#M29660</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2018-02-06T17:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy.mapping.AddLayer selection Funk (serious ESRI devs only)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375251#M29661</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Haaaaaar &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp; That was a self inflicted post-copy-pasta wound...&amp;nbsp; But still a distraction from the real issue!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Feb 2018 17:39:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375251#M29661</guid>
      <dc:creator>JosephArmbruster</dc:creator>
      <dc:date>2018-02-06T17:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy.mapping.AddLayer selection Funk (serious ESRI devs only)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375252#M29662</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Some last comments before I leave this thread to what it is:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;You requested that only "Serious ESRI devs" should respond. Rebecca, Joshua an&amp;nbsp;James are all MVP' with a large amount of experience with ArcGIS and Python&lt;/LI&gt;&lt;LI&gt;Rebecca asked you to provided the code using the syntax&amp;nbsp;highlighter, which you haven't done, making it more difficult to detect&amp;nbsp;problems in the code&lt;/LI&gt;&lt;LI&gt;You provided partial code using variable names that&amp;nbsp;don't match the data type and&amp;nbsp;aid misinterpretation of the code. Which led to the&amp;nbsp;valid suggestion of Joshua that you cannot get the FIDSet of a featureclass.&lt;/LI&gt;&lt;LI&gt;I assume that you have been marking several answers as "Not helpful". If so, this is not inviting the users to keep helping you.&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;If you are so sure that it is a software bug,&amp;nbsp; you should report it to support.&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck on solving it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Feb 2018 17:42:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375252#M29662</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2018-02-06T17:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy.mapping.AddLayer selection Funk (serious ESRI devs only)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375253#M29663</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;MVP and GISP mean almost nothing to me personally.&amp;nbsp; There are people who make careers out of accumulating thumbs&amp;nbsp;ups, which is what it is...&amp;nbsp; I've been doing this for years and typically do not have unlimited time to invest in forum interaction (reference the old, original esri forums...)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are two people who attempted to provided material value so-far on this issue, you and Joshua, and for that Thanks!&amp;nbsp; Even with the silly typo, it's not difficult to reproduce this issue.&amp;nbsp; If you change that text to new_layer, you'll see &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, I have opened an issue with ESRI support and a working .pyt with both sides of the tool.&amp;nbsp; If there was an attach file option here, i'd use it!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Feb 2018 18:29:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375253#M29663</guid>
      <dc:creator>JosephArmbruster</dc:creator>
      <dc:date>2018-02-06T18:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy.mapping.AddLayer selection Funk (serious ESRI devs only)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375254#M29664</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/395857_attachfile.png" style="width: 620px; height: 163px;" /&gt;&lt;/P&gt;&lt;P&gt;here you go&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Feb 2018 18:48:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375254#M29664</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-02-06T18:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy.mapping.AddLayer selection Funk (serious ESRI devs only)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375255#M29665</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Test code attached.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Feb 2018 19:07:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375255#M29665</guid>
      <dc:creator>JosephArmbruster</dc:creator>
      <dc:date>2018-02-06T19:07:11Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy.mapping.AddLayer selection Funk (serious ESRI devs only)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375256#M29666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If possible, implement arcpy.GetCount on the layer in the TOC rather than the desc.FIDSet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;mxd &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapDocument&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'CURRENT'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
df &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListDataFrames&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
lyr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListLayers&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"SomeLayerName"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; df&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
getCountMethod &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; int&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetCount_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lyr&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;getOutput&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddMessage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"getCountMethod: {}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;getCountMethod&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That seems to work just fine, even after the layer was added programmatically from another GP tool.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:21:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375256#M29666</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-11T17:21:25Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy.mapping.AddLayer selection Funk (serious ESRI devs only)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375257#M29667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;James,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I use the feature layer that was provided as an input to the tool within my function.&amp;nbsp; I shouldn't have to List and search for it again, if it's given to me&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, I am not using the FIDSet for anything besides a little debug output.&amp;nbsp; You could remove the lines from desc = arcpy.Describe(input_feature_class), all the way down to the 'no selection made' message if you want... same issue will surface.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem has something to do with the way the layer was added... because any subsequent add of a layer with the same Name will experience the issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Joe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Feb 2018 19:25:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-addlayer-selection-funk-serious-esri/m-p/375257#M29667</guid>
      <dc:creator>JosephArmbruster</dc:creator>
      <dc:date>2018-02-06T19:25:40Z</dc:date>
    </item>
  </channel>
</rss>

