<?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: Data Driven Pages - Page Name as output in Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/data-driven-pages-page-name-as-output-in-python/m-p/493467#M38709</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you &lt;A href="https://community.esri.com/migrated-users/16114"&gt;Charles-Andre Roy&lt;/A&gt;‌. I thought I had tried replacing index with my field name already, but somehow I got my wires crossed. All is working now.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 05 Dec 2014 16:13:44 GMT</pubDate>
    <dc:creator>JimmyMack</dc:creator>
    <dc:date>2014-12-05T16:13:44Z</dc:date>
    <item>
      <title>Data Driven Pages - Page Name as output in Python</title>
      <link>https://community.esri.com/t5/python-questions/data-driven-pages-page-name-as-output-in-python/m-p/493461#M38703</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, I'm trying to write a code to export maps with Data Driven Page in Python (arcpy module). I'm at my beginning...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My objective here is to use "Select Attributes by Location" tool to make a subset of my index layer (I don't want to export all index polygon). So I select some index polygons that intersects some polylines. Then I'd like to export 1 PDF map + 1 PNG map by index polygon. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;By default Data Driven Pages export the map by giving the page numbers to the output name. I seen a part of the code here elsewhere but it doesn't work. An error message appear: "&amp;lt;type 'exceptions.AttributeError'&amp;gt;: GetValue". Is it because through the loop, the cursor don't know which cell to get value from?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# Import arcpy module
import arcpy

# Local variables:
TCTquadrants_shp = "C:\\TCTData\\Layers\\PDF Maps\\TCTquadrants.shp"
CDA_trail_PDF_Dissolve_shp = "C:\\TCTData\\Layers\\PDF Maps\\CDA_trail_PDF_Dissolve.shp"
NL_quadrants_Layer = "NL_quadrants_Layer"
NL_trail = "NL_trail"
NL_quadrants_shp = "C:\\TCTData\\Test\\NL_quadrants.shp"
TCT_quadrants_Layer = "TCT_quadrants_Layer"
TCT_pageName = "C:\\TCTData\\Test\\TCT_pageName.shp"

# Process: Make Feature Layer (Quadrant)
arcpy.MakeFeatureLayer_management(TCTquadrants_shp, NL_quadrants_Layer, "\"quadrant\" = 'NL'", "", "FID FID VISIBLE NONE;Shape Shape VISIBLE NONE;Quadrant Quadrant VISIBLE NONE;Number Number VISIBLE NONE;index index VISIBLE NONE;index_more index_more VISIBLE NONE;X X VISIBLE NONE;Y Y VISIBLE NONE;Trail_1 Trail_1 VISIBLE NONE;Trail_2 Trail_2 VISIBLE NONE;Trail_3 Trail_3 VISIBLE NONE;Trail_4 Trail_4 VISIBLE NONE;Trail_5 Trail_5 VISIBLE NONE;Trail_6 Trail_6 VISIBLE NONE;Trail_7 Trail_7 VISIBLE NONE;TrailNames TrailNames VISIBLE NONE;Comment Comment VISIBLE NONE;CreatedBy CreatedBy VISIBLE NONE;UpdatedBy UpdatedBy VISIBLE NONE;State State VISIBLE NONE")

# Process: Make Feature Layer (Trail)
arcpy.MakeFeatureLayer_management(CDA_trail_PDF_Dissolve_shp, NL_trail, "\"ID_PROVINC\" = '01'", "", "FID FID VISIBLE NONE;Shape Shape VISIBLE NONE;ID_TRAILTY ID_TRAILTY VISIBLE NONE;ID_TRAILST ID_TRAILST VISIBLE NONE;Name_Trail Name_Trail VISIBLE NONE;ID_SEGMENT ID_SEGMENT VISIBLE NONE;ID_PROVINC ID_PROVINC VISIBLE NONE;Name Name VISIBLE NONE")

# Process: Select Layer By Location
arcpy.SelectLayerByLocation_management(NL_quadrants_Layer, "INTERSECT", NL_trail, "", "NEW_SELECTION")

# Process: Copy Features
arcpy.CopyFeatures_management(NL_quadrants_Layer, NL_quadrants_shp, "", "0", "0", "0")

# Process: Select and Copy Feature for Page Name
arcpy.CopyFeatures_management(NL_quadrants_shp, TCT_pageName, "", "0", "0", "0")

# Export Maps
mxd = arcpy.mapping.MapDocument(r"C:\\TCTData\\Test\\Trail_PDF_Maps_layout_NL.mxd")

# Use cursor to cycle through TCT_pageName feature class
cur = arcpy.SearchCursor(TCT_pageName)
row = cur.next()

# PDF
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
&amp;nbsp; mxd.dataDrivenPages.currentPageID = pageNum
&amp;nbsp; pageName = row.GetValue("index")
&amp;nbsp; arcpy.mapping.ExportToPDF(mxd, r"C:\TCTData\Test\No_" + pageName + ".pdf")
&amp;nbsp; row = cur.next()

&amp;nbsp; # PNG
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
&amp;nbsp; mxd.dataDrivenPages.currentPageID = pageNum
&amp;nbsp; pageName = row.getvalue("index")
&amp;nbsp; row = cur.next()
&amp;nbsp; arcpy.mapping.ExportToPNG(mxd, r"C:\TCTData\Test\No_" + pageName + ".png")
del mxd, cur, row&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the help&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jan 2011 14:09:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/data-driven-pages-page-name-as-output-in-python/m-p/493461#M38703</guid>
      <dc:creator>Charles-AndreRoy</dc:creator>
      <dc:date>2011-01-07T14:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: Data Driven Pages - Page Name as output in Python</title>
      <link>https://community.esri.com/t5/python-questions/data-driven-pages-page-name-as-output-in-python/m-p/493462#M38704</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I will reply to my own thread. I finally found my way to export page name as output instead of page number. For a reason that I ignore the function row.getvalue() doesn't work. I used the other way instead as pageRow.FIELDNAME. I don't need to use a cursor. Here is the code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
&amp;nbsp; mxd.dataDrivenPages.currentPageID = pageNum
&amp;nbsp; arcpy.AddMessage("Exporting PDF Map " + str(pageNum) + " of " + str(mxd.dataDrivenPages.pageCount))
&amp;nbsp; pageName = mxd.dataDrivenPages.pageRow.index
&amp;nbsp; arcpy.mapping.ExportToPDF(mxd, r"C:\TCTData\MAPS\PDF_MAPS\No_" + pageName + ".pdf", resolution=200)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:42:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/data-driven-pages-page-name-as-output-in-python/m-p/493462#M38704</guid>
      <dc:creator>Charles-AndreRoy</dc:creator>
      <dc:date>2021-12-11T21:42:52Z</dc:date>
    </item>
    <item>
      <title>Re: Data Driven Pages - Page Name as output in Python</title>
      <link>https://community.esri.com/t5/python-questions/data-driven-pages-page-name-as-output-in-python/m-p/493463#M38705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;A followup question to this is...can you get the page name without supplying the name field explicitly?&amp;nbsp; So far I can use a known page name to get pageID, but not the other way around.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 May 2011 16:51:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/data-driven-pages-page-name-as-output-in-python/m-p/493463#M38705</guid>
      <dc:creator>KarlHillstrom</dc:creator>
      <dc:date>2011-05-26T16:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: Data Driven Pages - Page Name as output in Python</title>
      <link>https://community.esri.com/t5/python-questions/data-driven-pages-page-name-as-output-in-python/m-p/493464#M38706</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello &lt;A href="https://community.esri.com/migrated-users/16114" target="_blank"&gt;Charles-Andre Roy&lt;/A&gt; ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a question related to yours (which you successfully solved). Whenever I try to set a string variable to mxd.dataDrivenPages.pageRow.index I get the error: "RuntimeError: Row: Field index does not exist" ... I am trying to export data driven pages to adobe illustrator using the page name. Here's what I have:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os, sys, string
from arcpy import env

mxd = arcpy.mapping.MapDocument("CURRENT")

for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.dataDrivenPages.currentPageID = pageNum
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Exporting PDF Map " + str(pageNum) + " of " + str(mxd.dataDrivenPages.pageCount))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pageName = mxd.dataDrivenPages.pageRow.index
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.ExportToAI(mxd, r"C:\Dropbox (WSA)\Tucson\PROJECTS ACTIVE\GSA\2014-58 Richfield Travel Routes\Maps\Site_Location\Site_Location_Map\_" + pageName + ".ai")
del mxd&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd appreciate any help! Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jimmy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:42:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/data-driven-pages-page-name-as-output-in-python/m-p/493464#M38706</guid>
      <dc:creator>JimmyMack</dc:creator>
      <dc:date>2021-12-11T21:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: Data Driven Pages - Page Name as output in Python</title>
      <link>https://community.esri.com/t5/python-questions/data-driven-pages-page-name-as-output-in-python/m-p/493465#M38707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jimmy,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wrote this code a long time ago, but as far as I remember it, the name of the field in the feature class layer is called "index". Remember that python is case sensitive, so "Index" is not the same as "index".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Dec 2014 15:28:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/data-driven-pages-page-name-as-output-in-python/m-p/493465#M38707</guid>
      <dc:creator>Charles-AndreRoy</dc:creator>
      <dc:date>2014-12-05T15:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: Data Driven Pages - Page Name as output in Python</title>
      <link>https://community.esri.com/t5/python-questions/data-driven-pages-page-name-as-output-in-python/m-p/493466#M38708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Karl,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I didn't look back to this since 3 years, so maybe the new arcpy allows to get the pageName automatically from the index field selected from the ArcMap dialog. But 3 years ago, the arcpy module was just getting the pageNum for the filename. The name field could be selected as an user input as well.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Dec 2014 15:33:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/data-driven-pages-page-name-as-output-in-python/m-p/493466#M38708</guid>
      <dc:creator>Charles-AndreRoy</dc:creator>
      <dc:date>2014-12-05T15:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: Data Driven Pages - Page Name as output in Python</title>
      <link>https://community.esri.com/t5/python-questions/data-driven-pages-page-name-as-output-in-python/m-p/493467#M38709</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you &lt;A href="https://community.esri.com/migrated-users/16114"&gt;Charles-Andre Roy&lt;/A&gt;‌. I thought I had tried replacing index with my field name already, but somehow I got my wires crossed. All is working now.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Dec 2014 16:13:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/data-driven-pages-page-name-as-output-in-python/m-p/493467#M38709</guid>
      <dc:creator>JimmyMack</dc:creator>
      <dc:date>2014-12-05T16:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: Data Driven Pages - Page Name as output in Python</title>
      <link>https://community.esri.com/t5/python-questions/data-driven-pages-page-name-as-output-in-python/m-p/493468#M38710</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Happy to help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Dec 2014 16:19:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/data-driven-pages-page-name-as-output-in-python/m-p/493468#M38710</guid>
      <dc:creator>Charles-AndreRoy</dc:creator>
      <dc:date>2014-12-05T16:19:00Z</dc:date>
    </item>
  </channel>
</rss>

