<?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: Python - Using data driven pages to select features from another layer to get attributes to text in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-using-data-driven-pages-to-select-features/m-p/78998#M6376</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try refreshing the active view right before you export the PDF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.RefreshActiveView()&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 10 Jun 2015 18:42:41 GMT</pubDate>
    <dc:creator>JuanOrozco</dc:creator>
    <dc:date>2015-06-10T18:42:41Z</dc:date>
    <item>
      <title>Python - Using data driven pages to select features from another layer to get attributes to text</title>
      <link>https://community.esri.com/t5/python-questions/python-using-data-driven-pages-to-select-features/m-p/78997#M6375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: Helvetica, sans-serif;"&gt;I am trying to loop through exporting data drive pages, select data from another layer based on the page getting exported, and write a row of the results of the selection to a text element.&amp;nbsp; Each page should have different results in text element.&amp;nbsp; For each page getting exported I I want to select all the parcels within the current page/feature getting exported and write the results to the text element.&amp;nbsp; What I have so far only writes the results for the first page on every page.&amp;nbsp; When it runs it does seem to select the parcels per page while exporting, but it does not re-write the results to the text element.&amp;nbsp; Not sure what I am missing?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Always run script in the mxd you are working on.
mxd = arcpy.mapping.MapDocument("CURRENT")


# Overwrites any existing features.
arcpy.env.overwriteOutput = True


# Uses the Dataframe called "Layers".
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]


# Parcel Text Element
ParcelText2 = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "ParcelsText2")[0]


# Data Driven Pages Export Sheets
ExportSheets = arcpy.mapping.Layer("Sheets_11x17")


# Parcels
Parcels = arcpy.mapping.Layer("Parcels")


# Data Driven Pages mxd abbreviation
ddp = mxd.dataDrivenPages


# Loop through DDP's
for pageNumb in range(1, mxd.dataDrivenPages.pageCount + 1):
&amp;nbsp;&amp;nbsp;&amp;nbsp; ddp.currentPageID = pageNumb


&amp;nbsp;&amp;nbsp;&amp;nbsp; # DDP Export Sheet duplicate which has the page definition Query
&amp;nbsp;&amp;nbsp;&amp;nbsp; SelectedSheet = arcpy.mapping.Layer("Sheets_11x172")


&amp;nbsp;&amp;nbsp;&amp;nbsp; # Exports Row page
&amp;nbsp;&amp;nbsp;&amp;nbsp; ExportSheetsPage = ddp.pageRow.PLAN_NUMBER


&amp;nbsp;&amp;nbsp;&amp;nbsp; # Select Parcels withing my SelectedSheet
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management(Parcels, "WITHIN", SelectedSheet)


&amp;nbsp;&amp;nbsp;&amp;nbsp; # Use SearchCursor to get Parcels value and write to Parcel Text Element
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows = arcpy.SearchCursor(Parcels)
&amp;nbsp;&amp;nbsp;&amp;nbsp; textValue = ""
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; textValue += row.getValue("MAP_PARCEL")
&amp;nbsp;&amp;nbsp;&amp;nbsp; ParcelText2.text = textValue


&amp;nbsp;&amp;nbsp;&amp;nbsp; # Export Sheets
&amp;nbsp;&amp;nbsp;&amp;nbsp; ddp.exportToPDF(r"Y:\GIS\GIS_Work\Working\parcel_test\maps\test.mxd")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:02:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-using-data-driven-pages-to-select-features/m-p/78997#M6375</guid>
      <dc:creator>deleted-user-MS0lE1F_0-sy</dc:creator>
      <dc:date>2021-12-10T23:02:57Z</dc:date>
    </item>
    <item>
      <title>Re: Python - Using data driven pages to select features from another layer to get attributes to text</title>
      <link>https://community.esri.com/t5/python-questions/python-using-data-driven-pages-to-select-features/m-p/78998#M6376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try refreshing the active view right before you export the PDF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.RefreshActiveView()&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jun 2015 18:42:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-using-data-driven-pages-to-select-features/m-p/78998#M6376</guid>
      <dc:creator>JuanOrozco</dc:creator>
      <dc:date>2015-06-10T18:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: Python - Using data driven pages to select features from another layer to get attributes to text</title>
      <link>https://community.esri.com/t5/python-questions/python-using-data-driven-pages-to-select-features/m-p/78999#M6377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;Try putting the ALL keyword in your export statement &lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//00s300000030000000" title="http://resources.arcgis.com/en/help/main/10.1/index.html#//00s300000030000000"&gt;ArcGIS Help 10.1&lt;/A&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;ddp.exportToPDF(r&lt;/SPAN&gt;&lt;SPAN class="string" style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: blue;"&gt;"Y:\GIS\GIS_Work\Working\parcel_test\maps\test.pdf","ALL"&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000;"&gt;) &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jun 2015 19:53:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-using-data-driven-pages-to-select-features/m-p/78999#M6377</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2015-06-10T19:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: Python - Using data driven pages to select features from another layer to get attributes to text</title>
      <link>https://community.esri.com/t5/python-questions/python-using-data-driven-pages-to-select-features/m-p/79000#M6378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I got it figured out.&amp;nbsp; I think "ALL" might work, but yes the keyword was the issue.&amp;nbsp; I ended up doing sort of a similar thing, I created a new pdf document before the loop, exported each sheet as "CURRENT" then appended the pages to the new pdf.&amp;nbsp; Thanks for the help.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jun 2015 11:38:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-using-data-driven-pages-to-select-features/m-p/79000#M6378</guid>
      <dc:creator>deleted-user-MS0lE1F_0-sy</dc:creator>
      <dc:date>2015-06-11T11:38:35Z</dc:date>
    </item>
  </channel>
</rss>

