Sycosys

error in execution sequence

Discussion created by Sycosys on Mar 22, 2012
Latest reply on Mar 22, 2012 by Sycosys
Hi,

What my code should be doing is zooming to the flow layer THEN Exporting the Group layer rather than exporting the group layer then zooming to Flow..

I am stumped how this is happening out of sequence, anyone have any ideas?

here is the printout from the tool


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



 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:
 
 print lyr                                      
 
 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!"

 


Outcomes