import arcpy, os #Specify map doc, data frame and visible layer mxd = arcpy.mapping.MapDocument(r"C:\Temp\Alex\Crossection_201210311a.mxd") df = arcpy.mapping.ListDataFrames(mxd, "Main")[0] visLyr = arcpy.mapping.ListLayers(mxd, "On-Site Mitigation Area_Python", df)[0] #Reference DDP object and iterate through pages ddp = mxd.dataDrivenPages for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1): print pageNum mxd.dataDrivenPages.currentPageID = pageNum visLyr.visible = False if ddp.pageRow.Source == "Willits": visLyr.visible = True ddp.exportToPDF(r"C:\Temp\Alex\Output\Page" + str(ddp.pageRow.Sorting_Field) + ".pdf", "CURRENT") del mxd
import arcpy, os #Specify map doc, data frame and table mxd = arcpy.mapping.MapDocument(r"K:\Projects_1\Caltrans\00543_09_Willits_from_URS\mapdoc\Crossection_2012\Crossection_20121024.mxd") df = arcpy.mapping.ListDataFrames(mxd)[0] mapLyr = arcpy.mapping.ListLayers(mxd, "Mapbook_table", df)[0] for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1): mxd.dataDrivenPages.currentPageID = pageNum rows = arcpy.SearchCursor(mapLyr) for row in rows: source = row.getValue ("Source") if source == "Willits": lyrName = "On-Site Mitigation Area_Python" lyr = arcpy.mapping.ListLayers(mxd, lyrName, df)[0] lyr.visible = True #This is turning the layer on based on if statement. ddp.exportToPDF(r"C:\Temp\Page" + str(pageNum) + ".pdf", "CURRENT") lyr.visible = False #This turns it back off for other maps. del mxd, df, lyr
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.