<?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: getting the selected features of one data frame selected in anothe in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-mapping-getting-the-selected-features-of-one/m-p/519114#M40644</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jason,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the code you require, take note of assumptions and adjusted accordingly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# Description: Passes selection from one DataFrame to another for the same layer. # Usage:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Designed to be run in Python Command line window. Code assumes layers are Shapefiles and a selection actually exists # Author:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Duncan Hornby # Created:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 27/11/13 import arcpy&amp;nbsp;&amp;nbsp; # Get map document and list of DataFrames, code assumes only 2 exist mxd = arcpy.mapping.MapDocument("CURRENT") l = arcpy.mapping.ListDataFrames(mxd)&amp;nbsp;&amp;nbsp; # Get DataFrames df1 = l[0] df2 = l[1]&amp;nbsp;&amp;nbsp; # Get layer from first dataframe and create a list of select FIDs layername = "yr89_clipped_water_as_polygons" # Change this to your layer name l1 = arcpy.mapping.ListLayers(mxd,layername,df1)[0] d = arcpy.Describe(l1) fids = d.FIDSet toselect = fids.replace(";",",")&amp;nbsp;&amp;nbsp; # Get second identical layer in second dataframe and do selection l2 = arcpy.mapping.ListLayers(mxd,layername,df2)[0] sQuery = '"FID" IN (' + toselect + ')' arcpy.SelectLayerByAttribute_management(l2,"NEW_SELECTION",sQuery)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 Nov 2013 14:28:02 GMT</pubDate>
    <dc:creator>DuncanHornby</dc:creator>
    <dc:date>2013-11-27T14:28:02Z</dc:date>
    <item>
      <title>arcpy mapping: getting the selected features of one data frame selected in another df</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-getting-the-selected-features-of-one/m-p/519113#M40643</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;does anyone have example code showing how to get the features that are already selected in one data frame to also select the same set of features that are in a different data frame?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Nov 2013 13:28:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-getting-the-selected-features-of-one/m-p/519113#M40643</guid>
      <dc:creator>jasonfargo</dc:creator>
      <dc:date>2013-11-27T13:28:09Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy mapping: getting the selected features of one data frame selected in anothe</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-getting-the-selected-features-of-one/m-p/519114#M40644</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jason,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the code you require, take note of assumptions and adjusted accordingly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# Description: Passes selection from one DataFrame to another for the same layer. # Usage:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Designed to be run in Python Command line window. Code assumes layers are Shapefiles and a selection actually exists # Author:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Duncan Hornby # Created:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 27/11/13 import arcpy&amp;nbsp;&amp;nbsp; # Get map document and list of DataFrames, code assumes only 2 exist mxd = arcpy.mapping.MapDocument("CURRENT") l = arcpy.mapping.ListDataFrames(mxd)&amp;nbsp;&amp;nbsp; # Get DataFrames df1 = l[0] df2 = l[1]&amp;nbsp;&amp;nbsp; # Get layer from first dataframe and create a list of select FIDs layername = "yr89_clipped_water_as_polygons" # Change this to your layer name l1 = arcpy.mapping.ListLayers(mxd,layername,df1)[0] d = arcpy.Describe(l1) fids = d.FIDSet toselect = fids.replace(";",",")&amp;nbsp;&amp;nbsp; # Get second identical layer in second dataframe and do selection l2 = arcpy.mapping.ListLayers(mxd,layername,df2)[0] sQuery = '"FID" IN (' + toselect + ')' arcpy.SelectLayerByAttribute_management(l2,"NEW_SELECTION",sQuery)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Nov 2013 14:28:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-getting-the-selected-features-of-one/m-p/519114#M40644</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2013-11-27T14:28:02Z</dc:date>
    </item>
  </channel>
</rss>

