brocko380

Script stops working after install SP3

Discussion created by brocko380 on Feb 26, 2012
Latest reply on Feb 27, 2012 by jbarrette-esristaff
The following code to work through data driven pages and populate text element then export to PDF has stop working after installing service pack 3.

Any suggestions would be appreciated

import arcpy
mxd = arcpy.mapping.MapDocument(r'G:\GIS WORK\2011\Plantation & Hazard Maps\PLANTATION MAP.mxd')
for pageNum in range(1,mxd.dataDrivenPages.pageCount +1):
    lyr = arcpy.mapping.ListLayers(mxd,"Area_Statement")[0]
    mxd.dataDrivenPages.currentPageID = pageNum
    PageNam = mxd.dataDrivenPages.pageRow.Page_Name
    Tract = mxd.dataDrivenPages.pageRow.Property
    woq = '"Admin"' +"="+"'"+Tract+"'"
    rows = arcpy.SearchCursor(lyr,woq,"","","Order_ A; PYear A")
    elm = arcpy.mapping.ListLayoutElements(mxd,"TEXT_ELEMENT","Year")[0]
    elmB = arcpy.mapping.ListLayoutElements(mxd,"TEXT_ELEMENT","Area")[0]
    elmC = arcpy.mapping.ListLayoutElements(mxd,"TEXT_ELEMENT","Plant")[0]
    elmD = arcpy.mapping.ListLayoutElements(mxd,"TEXT_ELEMENT","Species")[0]
    elm.text = ""
    elmB.text = ""
    elmC.text = ""
    elmD.text = ""
    for row in rows:
        elm.text += str(row.getValue("PYear"))+"\n"
        elmC.text += str(row.getValue("Feature"))+"\n"
        elmB.text += str(row.getValue("AArea"))+"\n"
        elmD.text += str(row.getValue("ASPECIES"))+"\n"
    arcpy.mapping.ExportToPDF (mxd,r'G:\ABP Maps\Working\Plantation'+"\ "+ str(PageNam) +" Plantation Map")
    elm.text = ""
    elmB.text = ""
    elmC.text = ""
    elmD.text = ""
del mxd

Outcomes