rphelan

List Layout Elements

Discussion created by rphelan on Jun 4, 2012
Latest reply on Jun 4, 2012 by m.gasior
I am new to python and arcpy.
Information about set up:
A layer called "Horizontal BH" with an attribute called "BOEInterna" exist in the MXD
A text element called "Text" exist in the MXD

I am trying to print table attributes from a layer in my mxd to a text element, here is my code:

import arcpy
mxd=arcpy.mapping.MapDocument("T:/phelanr/PayDay.mxd")
mapLyr=arcpy.mapping.ListLayers(mxd, "Horizontal BH")[0]
welElem=arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "Text")[0]
rows=arcpy.SearchCursor(mapLyr.dataSource)
row=rows.next()
welElem.text=row.getValue("BOEInterna")

When I run the code I get the following error:
Runtime error <type 'exceptions.IndexError'>: list index out of range

See the attached image to see how I have set up the text element.

Also I want to make sure this will print every record in the attribute table for the attribute being focused on into the text element.

Thanks for any help.

Attachments

Outcomes