Hi,
I am having an issue with getting this script to work. I wrote this a while ago and when I first wrote it, it worked perfectly. Now I am trying to use it again and I can't get it to work.
I need a PDF zoomed to each feature (Parcel), only showing one parcel at a time. The script should make a definition query for each parcel ID, zoom to that parcel, and export the map as a PDF. Everything works except it won't zoom in properly.
Can anyone figure out why this might be?
I have attached the code.
Thanks,
Erin
Code:
import arcpy
from arcpy.mapping import *
mapDoc = arcpy.mapping.MapDocument(r"C:\Users\CulpE\Desktop\Parcels.mxd")
dataFrames = ListDataFrames(mapDoc)
dataFrame = dataFrames[0]
adjParcel = r"C:\Users\CulpE\Desktop\parcels.shp"
parcel_layer = "Parcel"
lyrs = arcpy.mapping.ListLayers(mapDoc, '', dataFrame)
fieldList = ['PROP_ID']
for lyr in lyrs:
if lyr.name == parcel_layer:
with arcpy.da.SearchCursor(lyr, fieldList) as cursor:
for row in cursor:
lyr.definitionQuery = "PROP_ID ='" + str(row[0]) + "'"
print "PROP_ID='" + str(row[0]) + "'"
ext = lyr.getExtent()
dataFrame.extent = ext
dataFrame.scale *= 1.5
ExportToPDF (mapDoc, r"C:\Users\CulpE\Desktop\Parcel_" + str(row[0]) + ".pdf", "PAGE_LAYOUT")
del mapDoc
print "Closed map document"