I'm trying to use DDP to produce a map book for a series of works. Each item of work is a feature in a polyline feature class, and a copy of the class is being used to define my DDPs. I already have set up dynamic text, page definition queries etc.
As the work lines are variable in length, I want to constrain my map scale so that they are not zoomed in or out too far. My code:
import arcpy
from arcpy import env
env.workspace = r"U:"
mxd = arcpy.mapping.MapDocument(r"U:\EMS.mxd")
df = arcpy.mapping.ListDataFrames(mxd)[0]
ddp = mxd.dataDrivenPages
indexLayer = ddp.indexLayer
# def ddpScale():
# if df.scale < 6000:
# df.scale = 6000
# elif df.scale > 10000:
# df.scale = 10000
# else:
# df.scale = 10000
for i in range(1, mxd.dataDrivenPages.pageCount + 1):
mxd.dataDrivenPages.currentPageID = i
for scale in df.scale:
if df.scale < 6000:
df.scale = 6000
elif df.scale > 10000:
df.scale = 10000
else:
df.scale = 10000
#df.scale = ddpScale
ddp.exportToPDF(r"U:\test.pdf")
del mxd
The commented out lines were my attempt to define a function for setting the scale, but I opted for a elif statement instead. I basically want any pages with a scale less than 1:6000 to be 1:6000, and all others to be 1:10,0000.
As an addition, I would like lines that are above 1:10,000 originally to be split across multiple pages as needed.
How would I got about setting the scale in this manner?
The error I am getting:
Traceback (most recent call last):
File "C:/XXXddp.py", line
20, in <module>
for scale in df.scale:
TypeError: 'float' object is not iterable