<?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: Python code to include page index in output file name? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/data-driven-pages-python-code-to-include-page/m-p/130422#M10127</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//00s300000030000000"&gt;Using the pageRow property&lt;/A&gt;.&lt;BR /&gt;&lt;BR /&gt;So something like &lt;SPAN style="font-family:Courier New;"&gt;arcpy.mapping.ExportToJPEG(mxd, r"C:\output\\" + str(mxd.dataDrivenPages.pageRow.Reach_ID) + "_reachmap.jpg")&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Exactly like that!&amp;nbsp; I was messing around with getPageIDFromName and getting nowhere.&amp;nbsp; Thanks much!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 19 Nov 2013 20:41:17 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2013-11-19T20:41:17Z</dc:date>
    <item>
      <title>Data Driven Pages: Python code to include page index in output file name?</title>
      <link>https://community.esri.com/t5/python-questions/data-driven-pages-python-code-to-include-page/m-p/130420#M10125</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have used the DDP toolbar to set up DDP where 'Reach' is the index layer (as in river reach).&amp;nbsp; Each of the 100 Reaches has an ID, stored in the attribute table.&amp;nbsp; I want the output JPG name to be Reach ID plus _reachmap.jpg, concatenated.&amp;nbsp; However, instead of Reach ID I am getting a number between 1 and 100.&amp;nbsp; I have tried replacing pageNum with various other things but I get the same results or an error.&amp;nbsp; How can I get DDP to 'see' the Reach ID instead of the generic 1 to 100?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy mxd = arcpy.mapping.MapDocument("CURRENT") for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1): &amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.dataDrivenPages.currentPageID = pageNum &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.ExportToJPEG(mxd, r"C:\output\\" + str(pageNum) + "_reachmap.jpg") del mxd&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Nov 2013 20:24:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/data-driven-pages-python-code-to-include-page/m-p/130420#M10125</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-11-19T20:24:06Z</dc:date>
    </item>
    <item>
      <title>Re: Data Driven Pages: Python code to include page index in output file name?</title>
      <link>https://community.esri.com/t5/python-questions/data-driven-pages-python-code-to-include-page/m-p/130421#M10126</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;A class="jive-link-external-small" href="http://resources.arcgis.com/en/help/main/10.1/index.html#//00s300000030000000" rel="nofollow" target="_blank"&gt;Using the pageRow property&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So something like &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;arcpy.mapping.ExportToJPEG(mxd, r"C:\output\\" + str(mxd.dataDrivenPages.pageRow.Reach_ID) + "_reachmap.jpg")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Nov 2013 20:33:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/data-driven-pages-python-code-to-include-page/m-p/130421#M10126</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2013-11-19T20:33:36Z</dc:date>
    </item>
    <item>
      <title>Re: Data Driven Pages: Python code to include page index in output file name?</title>
      <link>https://community.esri.com/t5/python-questions/data-driven-pages-python-code-to-include-page/m-p/130422#M10127</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//00s300000030000000"&gt;Using the pageRow property&lt;/A&gt;.&lt;BR /&gt;&lt;BR /&gt;So something like &lt;SPAN style="font-family:Courier New;"&gt;arcpy.mapping.ExportToJPEG(mxd, r"C:\output\\" + str(mxd.dataDrivenPages.pageRow.Reach_ID) + "_reachmap.jpg")&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Exactly like that!&amp;nbsp; I was messing around with getPageIDFromName and getting nowhere.&amp;nbsp; Thanks much!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Nov 2013 20:41:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/data-driven-pages-python-code-to-include-page/m-p/130422#M10127</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-11-19T20:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: Data Driven Pages: Python code to include page index in output file name?</title>
      <link>https://community.esri.com/t5/python-questions/data-driven-pages-python-code-to-include-page/m-p/130423#M10128</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Something like this should work if you are referring to your ddp index field value. If it isn't your index field then just insert the name of the field instead of ddp.pageNameField.name&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
ddp = mxd.dataDrivenPages
for pageNum in range(1, ddp.pageCount + 1):
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.dataDrivenPages.currentPageID = pageNum
&amp;nbsp;&amp;nbsp;&amp;nbsp; id_val = ddp.pageRow.getValue(ddp.pageNameField.name)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.ExportToJPEG(mxd, r"C:\output\{0}_reachmap.jpg".format(id_val))
del mxd&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:20:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/data-driven-pages-python-code-to-include-page/m-p/130423#M10128</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-11T07:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: Data Driven Pages: Python code to include page index in output file name?</title>
      <link>https://community.esri.com/t5/python-questions/data-driven-pages-python-code-to-include-page/m-p/130424#M10129</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Something like this should work if you are referring to your ddp index field value. If it isn't your index field then just insert the name of the field instead of ddp.pageNameField.name&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
ddp = mxd.dataDrivenPages
for pageNum in range(1, ddp.pageCount + 1):
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.dataDrivenPages.currentPageID = pageNum
&amp;nbsp;&amp;nbsp;&amp;nbsp; id_val = ddp.pageRow.getValue(ddp.pageNameField.name)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.ExportToJPEG(mxd, r"C:\output\{0}_reachmap.jpg".format(id_val))
del mxd&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Looks good!&amp;nbsp; I will try both of these options as I build-out my script.&amp;nbsp; Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:20:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/data-driven-pages-python-code-to-include-page/m-p/130424#M10129</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T07:20:21Z</dc:date>
    </item>
  </channel>
</rss>

