EDIT: Ah ha! ok so the problem is that the code is exporting BEFORE it does the zoom to flow layer operation.. anyone have an idea on how to sort that out?Buried SystemsBuried Systems\AF - Auxiliary FeedwaterExporting C://Users//atimpson//Desktop//DDP_TEMP//AF - Auxiliary Feedwater mapbook.pdf.....Buried Systems\AF - Auxiliary Feedwater\FlowBuried Systems\AF - Auxiliary Feedwater\PipingBuried Systems\SA - Auxilary SteamExporting C://Users//atimpson//Desktop//DDP_TEMP//SA - Auxilary Steam mapbook.pdf.....Buried Systems\SA - Auxilary Steam\FlowBuried Systems\SA - Auxilary Steam\PipingBuried Systems\CW - Circulating WaterExporting C://Users//atimpson//Desktop//DDP_TEMP//CW - Circulating Water mapbook.pdf.....Buried Systems\CW - Circulating Water\FlowBuried Systems\CW - Circulating Water\PipingBuried Systems\CA - Compressed AirExporting C://Users//atimpson//Desktop//DDP_TEMP//CA - Compressed Air mapbook.pdf.....Buried Systems\CA - Compressed Air\FlowBuried Systems\CA - Compressed Air\PipingBuried Systems\CA - Compressed Air\Abandoned PipingBuried Systems\CI - Compressed Air InstrumentationExporting C://Users//atimpson//Desktop//DDP_TEMP//CI - Compressed Air Instrumentation mapbook.pdf.....Buried Systems\CI - Compressed Air Instrumentation\FlowBuried Systems\CI - Compressed Air Instrumentation\PipingThis code works, but the exports are a bit off.. The extents of each export are using the data from the previous layer and everything is one off. for instance export 3 gets the exents which were meant for export 2, export 4 gets the extents for export 3. All the layers are being mapped in the right order, its going right down the list, but the dataframe is for the previous layer in the exports. i have the code here and attached is a sample of the TOC structure the code is working with.
import arcpy
arcpy.env.overwriteOutput = True
mxd = arcpy.mapping.MapDocument("CURRENT")
textlist = arcpy.mapping.ListLayoutElements(mxd,"TEXT_ELEMENT")
#for txt in textlist:
#if txt.text == r"MAP SUBTITLE":
#subtitle = txt
layerlist = arcpy.mapping.ListLayers(mxd)
for lyr in layerlist:
if lyr.longName != lyr.name:
if "flow" in lyr.name.lower():
df = arcpy.mapping.ListDataFrames(mxd)[0]
arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION")
df.zoomToSelectedFeatures()
df.scale = df.scale * 1.15
arcpy.SelectLayerByAttribute_management(lyr, "CLEAR_SELECTION")
arcpy.RefreshActiveView()
del df
if lyr.visible == False:
lyr.visible = True
#subtitle.text = lyr.name
pdfpath = "C://Users//atimpson//Desktop//DDP_TEMP//" + lyr.name + r" mapbook.pdf"
print "Exporting " + pdfpath + "....."
arcpy.mapping.ExportToPDF(mxd, pdfpath)
lyr.visible = False
del mxd
print "Done!"