<?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 &amp;quot;Dynamic&amp;quot; Table using Python, DDP in Mapping Questions</title>
    <link>https://community.esri.com/t5/mapping-questions/quot-dynamic-quot-table-using-python-ddp/m-p/561713#M6044</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have just started using Python and I'm trying to create a dynamic table using Data Driven Pages and Python. I'm using data driven pages and have a page definiton query set to display only the points that are within the page index, and only shows those records in the attribute table. I'd like to create a table in my layout that dynamically updates a text element with certain fields from the queried attribute table. So far this is what I have:&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("CURRENT")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rows = arcpy.SearchCursor("DAMS")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;row = rows.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;while row:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; stateValue = row.getValue("DAM_NAME")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if elm.text == "LayoutLegend":&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; elm.text = (str(stateValue) + "\n")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; row = rows.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.mapping.ExportToPDF(mxd, r"C:\Documents and Settings\jquinn\Desktop\Dam Map\trial.pdf")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del mxd&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In replaces "LayoutLegend" with the dam name, but it adds the first record in the feature class instead of the records in the queried attribute table. It also doesn't iterate through, adding each record to the text element.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Clearly, the code needs a bit of work, so any help would be greatly appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jon&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 23 Dec 2010 14:37:24 GMT</pubDate>
    <dc:creator>JonathanQuinn</dc:creator>
    <dc:date>2010-12-23T14:37:24Z</dc:date>
    <item>
      <title>"Dynamic" Table using Python, DDP</title>
      <link>https://community.esri.com/t5/mapping-questions/quot-dynamic-quot-table-using-python-ddp/m-p/561713#M6044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have just started using Python and I'm trying to create a dynamic table using Data Driven Pages and Python. I'm using data driven pages and have a page definiton query set to display only the points that are within the page index, and only shows those records in the attribute table. I'd like to create a table in my layout that dynamically updates a text element with certain fields from the queried attribute table. So far this is what I have:&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("CURRENT")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rows = arcpy.SearchCursor("DAMS")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;row = rows.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;while row:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; stateValue = row.getValue("DAM_NAME")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if elm.text == "LayoutLegend":&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; elm.text = (str(stateValue) + "\n")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; row = rows.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.mapping.ExportToPDF(mxd, r"C:\Documents and Settings\jquinn\Desktop\Dam Map\trial.pdf")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del mxd&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In replaces "LayoutLegend" with the dam name, but it adds the first record in the feature class instead of the records in the queried attribute table. It also doesn't iterate through, adding each record to the text element.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Clearly, the code needs a bit of work, so any help would be greatly appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jon&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Dec 2010 14:37:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/quot-dynamic-quot-table-using-python-ddp/m-p/561713#M6044</guid>
      <dc:creator>JonathanQuinn</dc:creator>
      <dc:date>2010-12-23T14:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: "Dynamic" Table using Python, DDP</title>
      <link>https://community.esri.com/t5/mapping-questions/quot-dynamic-quot-table-using-python-ddp/m-p/561714#M6045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Jon,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I believe the reason you are getting the first record (and all other records) is because you are not applying a query to your search cursor.&amp;nbsp; In this case you want to perform a SelectLayerByLocation and pass in the geometry of the data frame envelope.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) don't put your ListLayoutElements within the loop, you only need to reference the text element once so move this line above the loop.&amp;nbsp; Depending on the complexity of the MXD, this could be a real performance problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2) You can remove the additional if statement if you use the wildcard parameter for ListLayoutElements, try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "elm = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "LayoutLegend")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope this helps,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Dec 2010 12:54:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/quot-dynamic-quot-table-using-python-ddp/m-p/561714#M6045</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2010-12-24T12:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: "Dynamic" Table using Python, DDP</title>
      <link>https://community.esri.com/t5/mapping-questions/quot-dynamic-quot-table-using-python-ddp/m-p/561715#M6046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Great, thank you for getting back to me, Jeff.&amp;nbsp; I'll give those recommendations a try.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Dec 2010 16:06:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/quot-dynamic-quot-table-using-python-ddp/m-p/561715#M6046</guid>
      <dc:creator>JonathanQuinn</dc:creator>
      <dc:date>2010-12-28T16:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: "Dynamic" Table using Python, DDP</title>
      <link>https://community.esri.com/t5/mapping-questions/quot-dynamic-quot-table-using-python-ddp/m-p/561716#M6047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jon:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Take a look at the 4th sample script provided with the DataFrame class.&amp;nbsp; It performs a SelectByLocation using the DataFrame extent as the selecting feature.&amp;nbsp; I think this is all you need.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/DataFrame/00s300000003000000/"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/DataFrame/00s300000003000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Dec 2010 14:37:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/quot-dynamic-quot-table-using-python-ddp/m-p/561716#M6047</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2010-12-29T14:37:20Z</dc:date>
    </item>
  </channel>
</rss>

