tags. Its the # button. You want to preserve indents.
Tracey,
A couple of comments:
- I don't see an mxd.save() in your code so how is it that you expect to see changes?
- If you are running this from the Python window, use "CURRENT" instead of the path to the file on disk.
- it would be much easier to read your code if you posted it withingtags. Its the # button. You want to preserve indents. Jeff
# Import system modules
I think the following script will do what you need. Make sure to save the MXD with ALL group layers checked off (and all layers within the group layer checked on). See attached screen shot. A field was added to the index layer called "GroupLayerName". It has the values "GroupLayer1, GroupLayer2, etc). After exporting to PDF, the script then turns the group layer back off again before going to the next DDP page.import arcpy mxd = arcpy.mapping.MapDocument(r"c:\Temp\test.mxd") ddp = mxd.dataDrivenPages for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1): mxd.dataDrivenPages.currentPageID = pageNum fieldValue = mxd.dataDrivenPages.pageRow.GroupLayerName for lyr in arcpy.mapping.ListLayers(mxd): if lyr.name == fieldValue: lyr.visible = True arcpy.mapping.ExportToPDF(mxd, r"C:\\Temp\\" + fieldValue + ".pdf") lyr.visible = False del mxd
import arcpy mxd = arcpy.mapping.MapDocument(someMXDpath) for lyr in arcpy.mapping.ListLayers(mxd): lyr.visible = False for lyr in arcpy.mapping.ListLayers(mxd): lyr.visble = True arcpy.mapping.ExportToPDF(mxd, somePDFpath) lyr.visble = False
Susan,
I don't know why this is not working for you but I have never tried duplicate index features like you are. This is definately a creative way to use DDP but I don't think this is the correct approach. You are trying to create a thematic map - extent remains the same but different layers or themes are displayed for each page.
The approach I would take is to not use DDP and use arcpy.mapping only. Lets say you have 14 different pages because there are 14 different images. To makes things really easy, I would order the images in the TOC the way I want them to be exported. Image 1 / Page 1 at the top, image 14 / page 14 at the bottom of the TOC.
Then I would do something like:import arcpy mxd = arcpy.mapping.MapDocument(someMXDpath) for lyr in arcpy.mapping.ListLayers(mxd): lyr.visible = False for lyr in arcpy.mapping.ListLayers(mxd): lyr.visble = True arcpy.mapping.ExportToPDF(mxd, somePDFpath) lyr.visble = False
The code obviously needs more logic if there are multiple data frames, sets of layers that are always visible, etc
Jeff