I have a mxd file with multiple layers I have to export to PNG/JPG. I would like to create a script which turns on layers one at the time before they are exported. So far I have come up with the following:
import arcpy, string mxd = arcpy.mapping.MapDocument("current") #Read input parameters from script tool LyrList = string.split.(arcpy.GetParameterAsText(0), ";") PNGPath = arcpy.GetParameterAsText(1) #Turn of all lyrs in list for lyr in arcpy.mapping.ListLayers(mxd, LyrList): lyr.visible = False #Turn on lyr and export as png one by one for lyr in arcpy.mapping.ListLayers(mxd, LyrList): lyr.visible = True arcpy.mapping.ExportToPNG(mxd, PNGPath+"\\" + lyr.name + ".png") lyr.visible = False del LyrList del mxd
For the LyrList I use a dialoge box with the parameter data-type as Layer. Does anyone have an idea how to get this script working? When I use the ListLayers wildcard the script does work, but since I have a lot of layerfiles which all hace a kind of unique name that does not do the job for me.
thnx a lot!