Sycosys

Anyone have any idea why this is happening?

Discussion created by Sycosys on Mar 22, 2012
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 Systems
Buried Systems\AF - Auxiliary Feedwater
Exporting C://Users//atimpson//Desktop//DDP_TEMP//AF - Auxiliary Feedwater mapbook.pdf.....
Buried Systems\AF - Auxiliary Feedwater\Flow
Buried Systems\AF - Auxiliary Feedwater\Piping
Buried Systems\SA - Auxilary Steam
Exporting C://Users//atimpson//Desktop//DDP_TEMP//SA - Auxilary Steam mapbook.pdf.....
Buried Systems\SA - Auxilary Steam\Flow
Buried Systems\SA - Auxilary Steam\Piping
Buried Systems\CW - Circulating Water
Exporting C://Users//atimpson//Desktop//DDP_TEMP//CW - Circulating Water mapbook.pdf.....
Buried Systems\CW - Circulating Water\Flow
Buried Systems\CW - Circulating Water\Piping
Buried Systems\CA - Compressed Air
Exporting C://Users//atimpson//Desktop//DDP_TEMP//CA - Compressed Air mapbook.pdf.....
Buried Systems\CA - Compressed Air\Flow
Buried Systems\CA - Compressed Air\Piping
Buried Systems\CA - Compressed Air\Abandoned Piping
Buried Systems\CI - Compressed Air Instrumentation
Exporting C://Users//atimpson//Desktop//DDP_TEMP//CI - Compressed Air Instrumentation mapbook.pdf.....
Buried Systems\CI - Compressed Air Instrumentation\Flow
Buried Systems\CI - Compressed Air Instrumentation\Piping



This 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!"

 

Attachments

Outcomes