<?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: reading a user text file to zoom to a particular area in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/reading-a-user-text-file-to-zoom-to-a-particular/m-p/90115#M7003</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In dfCounty the extent is constant correct? It is the whole county Im assuming. To show the extent of other data frames you can just use an extent indicator. Go to the dftown properties and turn on an extent indicator for dfTownship. Then in dfTownship turn on an extent indicator for dfSection. Also, easier than making a selection and clearing it just for symbology reasons, in the layer properties you can change the selection symbol color. Just make it no color and save a step in the code. I renamed some variables just to make it clear in my head and added some inline comments.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, re
mxd = arcpy.mapping.MapDocument("M:\\par-prod\\checking\\legal.mxd")
dfSection = arcpy.mapping.ListDataFrames(mxd, "Legal")[0]#Shows one section
dfTownship = arcpy.mapping.ListDataFrames(mxd, "section")[0]#Shows one township
dfCounty = arcpy.mapping.ListDataFrames(mxd, "township")[0] #Shows whole county
lyrSection = arcpy.mapping.ListLayers(mxd, "GCDB*", dfSection)[0]#For showing one section
lyrTownship = arcpy.mapping.ListLayers(mxd, "GCDB*", dfTownship)[0]#For showing one township
data_file = open('todo.txt', 'r')
for item in data_file:
&amp;nbsp;&amp;nbsp;&amp;nbsp; match=re.search(r'(\d*\D)(\d*\D)(\d*)',item) #splits 2S24E16 into '2S' '24E' '16' in a match object to use
&amp;nbsp;&amp;nbsp;&amp;nbsp; Town,Range,Sec=match.group(1),match.group(2),match.group(3) #sets the three parts just collected to variables
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(lyrTownship, "NEW_SELECTION", "TOWN LIKE '%s%s'"%(Town,Range))
&amp;nbsp;&amp;nbsp;&amp;nbsp; dfTownship.zoomToSelectedFeatures()
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(lyrSection, "NEW_SELECTION", "TOWN = '%s%s%s'"%(Town,Range,Sec))
&amp;nbsp;&amp;nbsp;&amp;nbsp; dfSection.zoomToSelectedFeatures()
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RefreshActiveView()
&amp;nbsp;&amp;nbsp;&amp;nbsp; for elm in arcpy.mapping.ListLayoutElements(mxd, "Text_Element"): 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if elm.name == "Date":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elm.text = 'Date: &amp;lt;dyn type="date" format="short"/&amp;gt;'
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if elm.name == "Location":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elm.text = "SEC %s, T%sR%s"%(Sec,Town,Range)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.PrintMap(mxd)
mxd.save&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When pasting code hit that little # in the second line under the post title to add the code tags automatically.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 23:26:53 GMT</pubDate>
    <dc:creator>ChrisMathers</dc:creator>
    <dc:date>2021-12-10T23:26:53Z</dc:date>
    <item>
      <title>reading a user text file to zoom to a particular area</title>
      <link>https://community.esri.com/t5/python-questions/reading-a-user-text-file-to-zoom-to-a-particular/m-p/90109#M6997</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am having a hard time trying to figure out this. I have a .txt file with township/range/sections that I need to read and than zoom to the section, refresh the map and export files from it and than go to the next one. Here is the code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument("M:\\par-prod\\checking\\bookmaps.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df = arcpy.mapping.ListDataFrames(mxd, "Legal")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lyr = arcpy.mapping.ListLayers(mxd, "GCDB*", df)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;data_file = open('todo.txt', 'r')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for item in data_file:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print item&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows = arcpy.SearchCursor(lyr)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = rows.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while row:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trs = row.getValue("TOWN")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if trs == item:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Township Range Section is "+trs&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = rows.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; del rows&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I know it reads the list (with the first print) but it only gets to the next print for the last item in the list. No matter how many are in the list it only seems to do the last item. What am I not seeing?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Mar 2011 19:59:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reading-a-user-text-file-to-zoom-to-a-particular/m-p/90109#M6997</guid>
      <dc:creator>MikePowell</dc:creator>
      <dc:date>2011-03-08T19:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: reading a user text file to zoom to a particular area</title>
      <link>https://community.esri.com/t5/python-questions/reading-a-user-text-file-to-zoom-to-a-particular/m-p/90110#M6998</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well you are only getting the last page because the cursor is going to the end and then stoping. To do it this way you will need to create a new cursor and then delete it for each item in the list. You could use the list to create a selection and then open the cursor. If you do that, the only objects the cursor will use are the selected ones. You can then just zoom from extent to extent with df.extent=extent. Or if you want to have a constant scale (and probably do since townships are all the same size) you can use df.panToExtent(extent)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
mxd = arcpy.mapping.MapDocument("M:\\par-prod\\checking\\bookmaps.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Legal")[0]
make query from list
select by attribute(query)
for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; shape=row.shape
&amp;nbsp;&amp;nbsp;&amp;nbsp; extent=shape.extent
&amp;nbsp;&amp;nbsp;&amp;nbsp; df.extent=extent
&amp;nbsp;&amp;nbsp;&amp;nbsp; export
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:26:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reading-a-user-text-file-to-zoom-to-a-particular/m-p/90110#M6998</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2021-12-10T23:26:50Z</dc:date>
    </item>
    <item>
      <title>Re: reading a user text file to zoom to a particular area</title>
      <link>https://community.esri.com/t5/python-questions/reading-a-user-text-file-to-zoom-to-a-particular/m-p/90111#M6999</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the reply. Sorry, I'm still a little new to python. First, I am sorry for my copying of the script and not replacing the indentation. Here is how it should look:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument("M:\\par-prod\\checking\\bookmaps.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df = arcpy.mapping.ListDataFrames(mxd, "Legal")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lyr = arcpy.mapping.ListLayers(mxd, "GCDB*", df)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;data_file = open('todo.txt', 'r')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for item in data_file:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print item&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows = arcpy.SearchCursor(lyr)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = rows.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while row:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trs = row.getValue("TOWN")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if trs == item:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Township Range Section is "+trs&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = rows.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; del rows&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I guess I am still a little confused on why the cursor is going to the end of the list and than running. I like the idea of using the list to create a selection. That would eliminate trying to compare what is in the list and what is in the field "TOWN", I think. I am confused though by your code example though. I am assuming "make query from List" and "select by attribute" are comments. I am not sure how to that. Isn't reading the list and than going through each item in the list, with the "for" statement, considered making a query from the list. I am still a little confused.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Mar 2011 15:48:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reading-a-user-text-file-to-zoom-to-a-particular/m-p/90111#M6999</guid>
      <dc:creator>MikePowell</dc:creator>
      <dc:date>2011-03-09T15:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: reading a user text file to zoom to a particular area</title>
      <link>https://community.esri.com/t5/python-questions/reading-a-user-text-file-to-zoom-to-a-particular/m-p/90112#M7000</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;What is the format of the text document? If you can give me a couple sample lines from it I can write up a script to show you. The 'make query from list' line would just be some simple string construction. 'select by attribute(query)' is &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByAttribute_management (in_layer_or_view, {selection_type}, {where_clause}).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;For this it would be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByAttribute_management (lyr, 'NEW_SELECTION',query).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;oh and the way to preserve indents is the use (CODE) (/CODE) but with [] instead of ()&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Mar 2011 19:16:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reading-a-user-text-file-to-zoom-to-a-particular/m-p/90112#M7000</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2011-03-09T19:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: reading a user text file to zoom to a particular area</title>
      <link>https://community.esri.com/t5/python-questions/reading-a-user-text-file-to-zoom-to-a-particular/m-p/90113#M7001</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I certainly apprecite the help. After writting the last message I figured out some of what you were referring to. This is what I have now:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(Code)[import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument("M:\\par-prod\\checking\\legal.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;dfmain = arcpy.mapping.ListDataFrames(mxd, "Legal")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;dfsec = arcpy.mapping.ListDataFrames(mxd, "section")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;dftown = arcpy.mapping.ListDataFrames(mxd, "township")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lyrmain = arcpy.mapping.ListLayers(mxd, "GCDB*", dfmain)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lyrsec = arcpy.mapping.ListLayers(mxd, "GCDB*", dfsec)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lyrtown = arcpy.mapping.ListLayers(mxd, "GCDB*", dftown)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;data_file = open('todo.txt', 'r')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for item in data_file:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(lyrsec, "NEW_SELECTION", "TOWN like '"+item[:5]+"'")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dfsec.zoomToSelectedFeatures()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(lyrsec, "CLEAR_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(lyrsec, "NEW_SELECTION", "TOWN = '"+item+"'")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(lyrtown, "NEW_SELECTION", "TOWN = '"+item+"'")&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(lyrmain, "NEW_SELECTION", "TOWN = '"+item+"'")&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; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dfmain.zoomToSelectedFeatures()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(lyrmain, "CLEAR_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RefreshActiveView()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for elm in arcpy.mapping.ListLayoutElements(mxd, "Text_Element"):&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if elm.name == "Date":&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elm.text = 'Date: &amp;lt;dyn type="date" format="short"/&amp;gt;'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if elm.name == "Location":&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elm.text = "SEC "+item[5:7]+", T"+item[:2]+"R"+item[2:5]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.save&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.PrintMap(mxd)]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That seems to work, but I am still having a problem. The map that I am setting up has 3 dataframes. One showing the county and a selected section showing where in the county, the second showing the township and the selected section highlighted and the third is the the main map showing that section. For the some reason the selection for the first 2 is not working because they are not highlighted (it did zoom to the correct township for the second dataframe). Also, if my list has more than one item in it (example 3) it will print 3 maps, but the first 2 maps will be the full extents of the county and not zoomed in to the correct section, but the third one prints fine. I don't understand why it is doing that. The todo.txt looks like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2S24E16&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1N26E16&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1S25E12&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am getting it but It just takes me some time. I appreciate the help that you are providing.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Mar 2011 21:35:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reading-a-user-text-file-to-zoom-to-a-particular/m-p/90113#M7001</guid>
      <dc:creator>MikePowell</dc:creator>
      <dc:date>2011-03-09T21:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: reading a user text file to zoom to a particular area</title>
      <link>https://community.esri.com/t5/python-questions/reading-a-user-text-file-to-zoom-to-a-particular/m-p/90114#M7002</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry for the indenting thing. I guess I didn't quite understand the use of Code(). I think you still can understand it. Thanks again&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I should mention that I am running this in PythonWIN. I prefer that over running it in ArcMap.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Mar 2011 21:37:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reading-a-user-text-file-to-zoom-to-a-particular/m-p/90114#M7002</guid>
      <dc:creator>MikePowell</dc:creator>
      <dc:date>2011-03-09T21:37:12Z</dc:date>
    </item>
    <item>
      <title>Re: reading a user text file to zoom to a particular area</title>
      <link>https://community.esri.com/t5/python-questions/reading-a-user-text-file-to-zoom-to-a-particular/m-p/90115#M7003</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In dfCounty the extent is constant correct? It is the whole county Im assuming. To show the extent of other data frames you can just use an extent indicator. Go to the dftown properties and turn on an extent indicator for dfTownship. Then in dfTownship turn on an extent indicator for dfSection. Also, easier than making a selection and clearing it just for symbology reasons, in the layer properties you can change the selection symbol color. Just make it no color and save a step in the code. I renamed some variables just to make it clear in my head and added some inline comments.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, re
mxd = arcpy.mapping.MapDocument("M:\\par-prod\\checking\\legal.mxd")
dfSection = arcpy.mapping.ListDataFrames(mxd, "Legal")[0]#Shows one section
dfTownship = arcpy.mapping.ListDataFrames(mxd, "section")[0]#Shows one township
dfCounty = arcpy.mapping.ListDataFrames(mxd, "township")[0] #Shows whole county
lyrSection = arcpy.mapping.ListLayers(mxd, "GCDB*", dfSection)[0]#For showing one section
lyrTownship = arcpy.mapping.ListLayers(mxd, "GCDB*", dfTownship)[0]#For showing one township
data_file = open('todo.txt', 'r')
for item in data_file:
&amp;nbsp;&amp;nbsp;&amp;nbsp; match=re.search(r'(\d*\D)(\d*\D)(\d*)',item) #splits 2S24E16 into '2S' '24E' '16' in a match object to use
&amp;nbsp;&amp;nbsp;&amp;nbsp; Town,Range,Sec=match.group(1),match.group(2),match.group(3) #sets the three parts just collected to variables
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(lyrTownship, "NEW_SELECTION", "TOWN LIKE '%s%s'"%(Town,Range))
&amp;nbsp;&amp;nbsp;&amp;nbsp; dfTownship.zoomToSelectedFeatures()
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(lyrSection, "NEW_SELECTION", "TOWN = '%s%s%s'"%(Town,Range,Sec))
&amp;nbsp;&amp;nbsp;&amp;nbsp; dfSection.zoomToSelectedFeatures()
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RefreshActiveView()
&amp;nbsp;&amp;nbsp;&amp;nbsp; for elm in arcpy.mapping.ListLayoutElements(mxd, "Text_Element"): 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if elm.name == "Date":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elm.text = 'Date: &amp;lt;dyn type="date" format="short"/&amp;gt;'
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if elm.name == "Location":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elm.text = "SEC %s, T%sR%s"%(Sec,Town,Range)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.PrintMap(mxd)
mxd.save&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When pasting code hit that little # in the second line under the post title to add the code tags automatically.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:26:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reading-a-user-text-file-to-zoom-to-a-particular/m-p/90115#M7003</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2021-12-10T23:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: reading a user text file to zoom to a particular area</title>
      <link>https://community.esri.com/t5/python-questions/reading-a-user-text-file-to-zoom-to-a-particular/m-p/90116#M7004</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well, at least I can say that I was getting there. Works great. I never heard about that "re" module before. I am also aware of the Extent Indicator, but for some reason, it will not highlight the appropriate section on the printed maps. I can't figure out why. If I do everything manually (setting up the indicator, zooming to another section) in ArcMap, it works fine and highlights the section just by zooming to the dfSection. It just won't highlight in the script. Everything in your script works though, and I am very happy that it is printing every map in the list correctly now. Do you have a reason why it was only printing the last item on the list correctly? I guess, I still don't see why it is working versus before. Is is because of that "re" module. Thanks for the help. I really appreciate it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Mar 2011 21:12:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reading-a-user-text-file-to-zoom-to-a-particular/m-p/90116#M7004</guid>
      <dc:creator>MikePowell</dc:creator>
      <dc:date>2011-03-11T21:12:49Z</dc:date>
    </item>
    <item>
      <title>Re: reading a user text file to zoom to a particular area</title>
      <link>https://community.esri.com/t5/python-questions/reading-a-user-text-file-to-zoom-to-a-particular/m-p/90117#M7005</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;RE is regular expression. It is a module with syntax common to many languages that is for parsing text. The problem with slicing strings like you were doing is that in a case like this you may have 2S24E16, but the next line is 1S5E1. This would break your indexes and the selection wouldnt work. With re you can search for text that matches a format that you define. r'(\d*\D)(\d*\D)(\d*)' searches for any number of digits followed by a letter, any number of digits followed by a letter, and then a any number of digits. By using () I tell re that I want the match object to break it into the pieces that I want. So 2S24E16 into '2S' '24E' '16' in a match object to use.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Mar 2011 12:21:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reading-a-user-text-file-to-zoom-to-a-particular/m-p/90117#M7005</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2011-03-14T12:21:44Z</dc:date>
    </item>
    <item>
      <title>Re: reading a user text file to zoom to a particular area</title>
      <link>https://community.esri.com/t5/python-questions/reading-a-user-text-file-to-zoom-to-a-particular/m-p/90118#M7006</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Well, at least I can say that I was getting there. Works great. I never heard about that "re" module before. I am also aware of the Extent Indicator, but for some reason, it will not highlight the appropriate section on the printed maps. I can't figure out why. If I do everything manually (setting up the indicator, zooming to another section) in ArcMap, it works fine and highlights the section just by zooming to the dfSection. It just won't highlight in the script. Everything in your script works though, and I am very happy that it is printing every map in the list correctly now. Do you have a reason why it was only printing the last item on the list correctly? I guess, I still don't see why it is working versus before. Is is because of that "re" module. Thanks for the help. I really appreciate it.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Do you think you could package this up as a tool and share it?&amp;nbsp; I would really love to have some way to zoom to TRS, but I have NO scripting ability. I would be so thankful!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Apr 2011 19:33:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reading-a-user-text-file-to-zoom-to-a-particular/m-p/90118#M7006</guid>
      <dc:creator>KellyLarvie</dc:creator>
      <dc:date>2011-04-12T19:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: reading a user text file to zoom to a particular area</title>
      <link>https://community.esri.com/t5/python-questions/reading-a-user-text-file-to-zoom-to-a-particular/m-p/90119#M7007</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Sorry for the indenting thing. I guess I didn't quite understand the use of Code(). I think you still can understand it. Thanks again&lt;BR /&gt;&lt;BR /&gt;I should mention that I am running this in PythonWIN. I prefer that over running it in ArcMap.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I had the same problem posting code when I started using the forum.&amp;nbsp; If you put &lt;/SPAN&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt; code goes in between these two wrappers &lt;/PRE&gt;&lt;SPAN&gt; start your code with "CODE" in brackets and end with "/CODE" in brackets&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Apr 2011 20:26:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/reading-a-user-text-file-to-zoom-to-a-particular/m-p/90119#M7007</guid>
      <dc:creator>TerrySilveus</dc:creator>
      <dc:date>2011-04-12T20:26:57Z</dc:date>
    </item>
  </channel>
</rss>

