<?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 - PICTURE_ELEMENT - SourceImage changes in Mapping Questions</title>
    <link>https://community.esri.com/t5/mapping-questions/data-driven-pages-picture-element-sourceimage/m-p/511917#M5476</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here is your corrected code that was on the previous post.&amp;nbsp; It is much easier to read when &lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; tags are wrapped around it via these forum posts. See below.

Your code suggests to me that you are running it as a stand-alone script because you are importing arcpy and NOT using the keyword CURRENT.&amp;nbsp; I take it that your exported PDFs do have the correct images.&amp;nbsp; If you want to run your code in the Python window and see ArcMap update from page to page while your script is running then you would need to use arcpy.RefreshActiveView().&amp;nbsp; I also suggest that you insert a time delay.

Jeff

&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Temp\Photo.mxd")
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
&amp;nbsp; mxd.dataDrivenPages.currentPageID = pageNum
&amp;nbsp; imageName = mxd.dataDrivenPages.pageRow.getValue("image4map")
&amp;nbsp; for elm in arcpy.mapping.ListLayoutElements(mxd,"PICTURE_ELEMENT"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if elm.name == "photo1":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elm.sourceImage = "C:\\Temp\\" + imageName
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.ExportToPDF(mxd, r"C:\Temp\\" + str(pageNum) + ".pdf")
del mxd&lt;/PRE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 22:24:45 GMT</pubDate>
    <dc:creator>JeffBarrette</dc:creator>
    <dc:date>2021-12-11T22:24:45Z</dc:date>
    <item>
      <title>Data Driven Pages - PICTURE_ELEMENT - SourceImage changes</title>
      <link>https://community.esri.com/t5/mapping-questions/data-driven-pages-picture-element-sourceimage/m-p/511916#M5475</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Using a previous script posted on this forum, I've gotten the data-driven layouts to print out pdfs with an image (PICTURE_ELEMENT) that changes based on an attribute of the index layer storing the image name (using sourceImage).&amp;nbsp; However, the ArcMap displayed pages do not update the image source and continues to use the first image.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is the PICTURE_ELEMENT supposed to change on the layouts for each data driven page as well as the output to pdfs?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the sort-of working code:&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(r"G:\NEPacific\Data-types\maps\andra-datadriven-test-map.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;imagePath = "G:\\NEPacific\Data-types\Vent-locations\Axial\images\\"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; mxd.dataDrivenPages.currentPageID = pageNum&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; imageName = mxd.dataDrivenPages.pageRow.getValue("image4map")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; for elm in arcpy.mapping.ListLayoutElements(mxd,"PICTURE_ELEMENT"):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; if elm.name == "photo1":&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; nextImage = (str(imagePath) + str(imageName))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; elm.sourceImage = nextImage&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; print "Exporting Page {0} of {1}".format(str(mxd.dataDrivenPages.currentPageID), str(mxd.dataDrivenPages.pageCount))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; arcpy.mapping.ExportToPDF(mxd, r"G:\NEPacific\Data-types\maps\andra-datadriven-test-map.mxd" + str(pageNum) + ".pdf")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del mxd&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 May 2011 21:52:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/data-driven-pages-picture-element-sourceimage/m-p/511916#M5475</guid>
      <dc:creator>AndraBobbitt</dc:creator>
      <dc:date>2011-05-03T21:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: Data Driven Pages - PICTURE_ELEMENT - SourceImage changes</title>
      <link>https://community.esri.com/t5/mapping-questions/data-driven-pages-picture-element-sourceimage/m-p/511917#M5476</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here is your corrected code that was on the previous post.&amp;nbsp; It is much easier to read when &lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; tags are wrapped around it via these forum posts. See below.

Your code suggests to me that you are running it as a stand-alone script because you are importing arcpy and NOT using the keyword CURRENT.&amp;nbsp; I take it that your exported PDFs do have the correct images.&amp;nbsp; If you want to run your code in the Python window and see ArcMap update from page to page while your script is running then you would need to use arcpy.RefreshActiveView().&amp;nbsp; I also suggest that you insert a time delay.

Jeff

&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Temp\Photo.mxd")
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
&amp;nbsp; mxd.dataDrivenPages.currentPageID = pageNum
&amp;nbsp; imageName = mxd.dataDrivenPages.pageRow.getValue("image4map")
&amp;nbsp; for elm in arcpy.mapping.ListLayoutElements(mxd,"PICTURE_ELEMENT"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if elm.name == "photo1":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elm.sourceImage = "C:\\Temp\\" + imageName
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.ExportToPDF(mxd, r"C:\Temp\\" + str(pageNum) + ".pdf")
del mxd&lt;/PRE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:24:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/data-driven-pages-picture-element-sourceimage/m-p/511917#M5476</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2021-12-11T22:24:45Z</dc:date>
    </item>
  </channel>
</rss>

