brocko380

SearchCursor and TextElement

Discussion created by brocko380 on Feb 3, 2011
Latest reply on Feb 4, 2011 by bposthumus
Hi i Have the following script

import arcpy
mxd = arcpy.mapping.MapDocument(r'G:\GIS WORK\2010\arcgis10 hazard map\Plantation MAP 2010.mxd')
for pageNum in range(1,mxd.dataDrivenPages.pageCount +1):
    lyr = arcpy.mapping.ListLayers(mxd,"Area")[0]
    mxd.dataDrivenPages.currentPageID = pageNum
    PageNam = mxd.dataDrivenPages.pageRow.Page_Name
    Tract = mxd.dataDrivenPages.pageRow.Property
    woq = '"Tract_name"' +"="+"'"+Tract+"'"
    rows = arcpy.SearchCursor(lyr,woq)
    elm = arcpy.mapping.ListLayoutElements(mxd,"TEXT_ELEMENT","Type")[0]
    for row in rows:
        TText = row.getValue("SPECIES")+"     "+row.getValue("COVERTYPEC")+ "      "+str(row.getValue("ESTABLISHD"))+"       "+str(row.getValue("AreaA"))
        elm.text = str(TText)
    arcpy.mapping.ExportToPDF (mxd,r'G:\ABP Maps\Plantation Maps'+"\Plantation Maps " + str(PageNam))
del mxd

It will run fine but only will only place the last row in the text element, if i replace elm.text with a print command it will print all rows so i know searchcursor is working as i wish.

Any ideas on how to fix this issue.
cheers

Outcomes