Hi Raymond,of course I could post the code of the Python script:
#!/arcgisserver/arcgis/server/tools/python
#
# arcpy.GetParameterAsText(0): Kompletter Pfad der MXD
# arcpy.GetParameterAsText(1): Ausgabepfad fuer die Bilder
# arcpy.GetParameterAsText(2): Praefix fuer die Ausgabedatei, Nummerierung kommt aus Kartenserien-Konfiguration, Dateiendung wird angehaengt
# arcpy.GetParameterAsText(3): Debug-Flag
import arcpy
mxd = arcpy.mapping.MapDocument(arcpy.GetParameterAsText(0))
print arcpy.GetParameterAsText(0)
debugOn = arcpy.GetParameterAsText(3)
outPath = arcpy.GetParameterAsText(1)
outPrefix = arcpy.GetParameterAsText(2)
def getOutputName(prefix):
result = prefix + str(ddp.pageRow.getValue(ddp.pageNameField.name)) + ".png"
return result
print "Start exporting %s PNGs" % (mxd.dataDrivenPages.pageCount)
maxRange = mxd.dataDrivenPages.pageCount + 1
if (debugOn == "1"):
for lyr in arcpy.mapping.ListLayers(mxd):
#get the source from the layer
if lyr.supports("workspacePath"):
source = lyr.workspacePath
print "%s -> %s" % (lyr, source)
maxRange = 15
for pageNum in range(1, maxRange):
if (debugOn == "1"):
print "Page %s" % (pageNum)
mxd.dataDrivenPages.currentPageID = pageNum
ddp = mxd.dataDrivenPages
if (debugOn == "1"):
print "Exporting page {0} of {1}".format(str(mxd.dataDrivenPages.currentPageID), str(maxRange))
outputName = getOutputName(outPrefix)
print str(outPath) + "/" + str(outputName)
arcpy.mapping.ExportToPNG(mxd, str(outPath) + "/" + str(outputName), resolution=150)
The first parameter gets the absolute path of the mxd, the second is for the outputpath of the PNGs, the third is a prefix for the PNGs name, to put all PNGs of the three MXDs together in one path. The fourth parameter is just for debugging/testing.The script is not served as as GP. As I start working on this topic, I got trouble with writing the files, and so we just used the script itself. In fact we (will) call the python script in an shell script. This shell script also produces PDF reports with the PNGs.