<?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: Selecting Data Frames for Python Scripting in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/selecting-data-frames-for-python-scripting/m-p/381216#M30032</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I have a MXD with 5 data frames, the main data frame is running the Data Driven Pages for my Assessor Parcel Maps.&amp;nbsp; The second data frame shows the Township and Range of the page, third data frame shows the section within the township and range, and the fourth data frame shows the different divisions within the section.&amp;nbsp; I want to write a script that will prompt the user for those three pieces of information - TR, SECTION, and DIVISION - and have the page update automatically.&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;In my limited Python Scripting I am having trouble selecting layers in non active data frames.&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;The next step will be to map the selections according to users input...... &lt;BR /&gt;&lt;BR /&gt;import arcpy&lt;BR /&gt;mxd = arcpy.mapping.MapDocument ('CURRENT')&lt;BR /&gt;df = arcpy.mapping.ListDataFrames(mxd) [1]&lt;BR /&gt;mxd.activeView = df&lt;BR /&gt;layer = arcpy.GetParameterAsText (0)&lt;BR /&gt;grid = arcpy.GetParameterAsText (1)&lt;BR /&gt;arcpy.AddMessage (grid)&lt;BR /&gt;selstring = "TAG LIKE " + "'" + grid + "'"&lt;BR /&gt;arcpy.AddMessage("Selection string = " + selstring)&lt;BR /&gt;arcpy.SelectLayerByAttribute_management (layer, "NEW_SELECTION", selstring)&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sounds to me like you need to run the SelectLayerByAttribute on each dataframe by constructing a for loop for ListDataFrames. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
layer = arcpy.GetParameterAsText (0)
grid = arcpy.GetParameterAsText (1)
arcpy.AddMessage (grid)
selstring = "TAG LIKE " + "'" + grid + "'"
arcpy.AddMessage("Selection string = " + selstring)
mxd = arcpy.mapping.MapDocument ('CURRENT')
dfs = arcpy.mapping.ListDataFrames(mxd)
for df in dfs:
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.activeView = df
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management (layer, "NEW_SELECTION", selstring)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 17:34:51 GMT</pubDate>
    <dc:creator>deleted-user-1T_bOHag6M8d</dc:creator>
    <dc:date>2021-12-11T17:34:51Z</dc:date>
    <item>
      <title>Selecting Data Frames for Python Scripting</title>
      <link>https://community.esri.com/t5/python-questions/selecting-data-frames-for-python-scripting/m-p/381211#M30027</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a .mxd that contains 5 data frames.&amp;nbsp; I am trying to write a script that will first select the appropriate data frame for the script to process.&amp;nbsp; Is this possible?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Aug 2011 17:50:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selecting-data-frames-for-python-scripting/m-p/381211#M30027</guid>
      <dc:creator>ChadFoster</dc:creator>
      <dc:date>2011-08-29T17:50:17Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting Data Frames for Python Scripting</title>
      <link>https://community.esri.com/t5/python-questions/selecting-data-frames-for-python-scripting/m-p/381212#M30028</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can do this by specifying an index value.&amp;nbsp; Say, for example, you want to select the data frame called 'Philadelphia', and it's the 3rd data frame in your MXD.&amp;nbsp; You would use the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;df = arcpy.mapping.ListDataFrames(mxd)[2]&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The first data frame in your MXD starts with index 0.&amp;nbsp; Here is some further information:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s30000001p000000.htm"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s30000001p000000.htm&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Aug 2011 18:55:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selecting-data-frames-for-python-scripting/m-p/381212#M30028</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2011-08-29T18:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting Data Frames for Python Scripting</title>
      <link>https://community.esri.com/t5/python-questions/selecting-data-frames-for-python-scripting/m-p/381213#M30029</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;ok, i get that syntax and it appears like it is working but I would like to select and activate that data frame.&amp;nbsp; Maybe my question should have been, can I activate a data frame for my script to work?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Aug 2011 20:57:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selecting-data-frames-for-python-scripting/m-p/381213#M30029</guid>
      <dc:creator>ChadFoster</dc:creator>
      <dc:date>2011-08-29T20:57:43Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting Data Frames for Python Scripting</title>
      <link>https://community.esri.com/t5/python-questions/selecting-data-frames-for-python-scripting/m-p/381214#M30030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;ok, i get that syntax and it appears like it is working but I would like to select and activate that data frame.&amp;nbsp; Maybe my question should have been, can I activate a data frame for my script to work?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;What are you trying to accomplish in the selected dataframe?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Aug 2011 14:51:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selecting-data-frames-for-python-scripting/m-p/381214#M30030</guid>
      <dc:creator>deleted-user-1T_bOHag6M8d</dc:creator>
      <dc:date>2011-08-30T14:51:15Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting Data Frames for Python Scripting</title>
      <link>https://community.esri.com/t5/python-questions/selecting-data-frames-for-python-scripting/m-p/381215#M30031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a MXD with 5 data frames, the main data frame is running the Data Driven Pages for my Assessor Parcel Maps.&amp;nbsp; The second data frame shows the Township and Range of the page, third data frame shows the section within the township and range, and the fourth data frame shows the different divisions within the section.&amp;nbsp; I want to write a script that will prompt the user for those three pieces of information - TR, SECTION, and DIVISION - and have the page update automatically.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In my limited Python Scripting I am having trouble selecting layers in non active data frames.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The next step will be to map the selections according to users input...... &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument ('CURRENT')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df = arcpy.mapping.ListDataFrames(mxd) [1]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd.activeView = df&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;layer = arcpy.GetParameterAsText (0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;grid = arcpy.GetParameterAsText (1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage (grid)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;selstring = "TAG LIKE " + "'" + grid + "'"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("Selection string = " + selstring)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByAttribute_management (layer, "NEW_SELECTION", selstring)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Aug 2011 15:33:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selecting-data-frames-for-python-scripting/m-p/381215#M30031</guid>
      <dc:creator>ChadFoster</dc:creator>
      <dc:date>2011-08-30T15:33:05Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting Data Frames for Python Scripting</title>
      <link>https://community.esri.com/t5/python-questions/selecting-data-frames-for-python-scripting/m-p/381216#M30032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I have a MXD with 5 data frames, the main data frame is running the Data Driven Pages for my Assessor Parcel Maps.&amp;nbsp; The second data frame shows the Township and Range of the page, third data frame shows the section within the township and range, and the fourth data frame shows the different divisions within the section.&amp;nbsp; I want to write a script that will prompt the user for those three pieces of information - TR, SECTION, and DIVISION - and have the page update automatically.&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;In my limited Python Scripting I am having trouble selecting layers in non active data frames.&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;The next step will be to map the selections according to users input...... &lt;BR /&gt;&lt;BR /&gt;import arcpy&lt;BR /&gt;mxd = arcpy.mapping.MapDocument ('CURRENT')&lt;BR /&gt;df = arcpy.mapping.ListDataFrames(mxd) [1]&lt;BR /&gt;mxd.activeView = df&lt;BR /&gt;layer = arcpy.GetParameterAsText (0)&lt;BR /&gt;grid = arcpy.GetParameterAsText (1)&lt;BR /&gt;arcpy.AddMessage (grid)&lt;BR /&gt;selstring = "TAG LIKE " + "'" + grid + "'"&lt;BR /&gt;arcpy.AddMessage("Selection string = " + selstring)&lt;BR /&gt;arcpy.SelectLayerByAttribute_management (layer, "NEW_SELECTION", selstring)&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sounds to me like you need to run the SelectLayerByAttribute on each dataframe by constructing a for loop for ListDataFrames. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
layer = arcpy.GetParameterAsText (0)
grid = arcpy.GetParameterAsText (1)
arcpy.AddMessage (grid)
selstring = "TAG LIKE " + "'" + grid + "'"
arcpy.AddMessage("Selection string = " + selstring)
mxd = arcpy.mapping.MapDocument ('CURRENT')
dfs = arcpy.mapping.ListDataFrames(mxd)
for df in dfs:
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.activeView = df
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management (layer, "NEW_SELECTION", selstring)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:34:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selecting-data-frames-for-python-scripting/m-p/381216#M30032</guid>
      <dc:creator>deleted-user-1T_bOHag6M8d</dc:creator>
      <dc:date>2021-12-11T17:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting Data Frames for Python Scripting</title>
      <link>https://community.esri.com/t5/python-questions/selecting-data-frames-for-python-scripting/m-p/381217#M30033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;When I try that code for selecting a different data frame it disappears from my table of contents.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Sep 2011 20:12:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selecting-data-frames-for-python-scripting/m-p/381217#M30033</guid>
      <dc:creator>ChadFoster</dc:creator>
      <dc:date>2011-09-28T20:12:39Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting Data Frames for Python Scripting</title>
      <link>https://community.esri.com/t5/python-questions/selecting-data-frames-for-python-scripting/m-p/381218#M30034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;When I try that code for selecting a different data frame it disappears from my table of contents.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure I understand. The data frame disappears? As in, it gets deleted from the mxd?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Sep 2011 14:24:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selecting-data-frames-for-python-scripting/m-p/381218#M30034</guid>
      <dc:creator>deleted-user-1T_bOHag6M8d</dc:creator>
      <dc:date>2011-09-29T14:24:40Z</dc:date>
    </item>
  </channel>
</rss>

