MapExportTools.py
def execute(self, parameters, messages):
        """The source code of the tool."""
        mapFile = parameters[0].valueAsText
        outDir = parameters[1].valueAsText
        exportList = parameters[2].valueAsText
        outFormat = parameters[3].value
        # open mxd for reading
        mxd = arcpy.mapping.MapDocument(mapFile)
        totalPages = mxd.dataDrivenPages.pageCount
        # loop through list of pages
        for page in range(1, totalPages + 1):
            mxd.dataDrivenPages.currentPageID = page
            pageField = mxd.dataDrivenPages.pageNameField.name
            pageName = str(page) + "-" + mxd.dataDrivenPages.pageRow.getValue(pageField)
            outPage = outDir + "\\" + pageName
            if pageName in exportList:
                arcpy.AddMessage("Exporting " + outPage)
                if outFormat == "PNG":
                    arcpy.mapping.ExportToPNG(mxd, outPage + ".png", resolution=300)
                if outFormat == "PDF":
                    arcpy.mapping.ExportToPDF(mxd, outPage + ".pdf", resolution=300)
                if outFormat == "JPEG":
                    arcpy.mapping.ExportToJPEG(mxd, outPage + ".jpg", resolution=300)
The source code of the tool.
The source code of the tool.
The source code of the tool .
def execute(self, parameters, messages):
        mapFile = parameters[0].valueAsText
        outDir = parameters[1].valueAsText
        exportList = parameters[2].valueAsText
        outFormat = parameters[3].value
        mxd = arcpy.mapping.MapDocument(mapFile)
        totalPages = mxd.dataDrivenPages.pageCount
        for page in range(1, totalPages + 1):
            mxd.dataDrivenPages.currentPageID = page
            pageField = mxd.dataDrivenPages.pageNameField.name
            pageName = str(page) + "-" + mxd.dataDrivenPages.pageRow.getValue(pageField)
            outPage = outDir + "\\" + pageName
            if pageName in exportList:
                arcpy.AddMessage("Exporting " + outPage)
                if outFormat == "PNG":
                    arcpy.mapping.ExportToPNG(mxd, outPage + ".png", resolution=300)
                if outFormat == "PDF":
                    arcpy.mapping.ExportToPDF(mxd, outPage + ".pdf", resolution=300)
                if outFormat == "JPEG":
                    arcpy.mapping.ExportToJPEG(mxd, outPage + ".jpg", resolution=300)
def execute ( self , parameters , messages ) : mapFile = parameters [ 0 ] . valueAsText outDir = parameters [ 1 ] . valueAsText exportList = parameters [ 2 ] . valueAsText outFormat = parameters [ 3 ] . value mxd = arcpy . mapping . MapDocument ( mapFile ) totalPages = mxd . dataDrivenPages . pageCount for page in range ( 1 , totalPages + 1 ) : mxd . dataDrivenPages . currentPageID = page pageField = mxd . dataDrivenPages . pageNameField . name pageName = str ( page ) + "-" + mxd . dataDrivenPages . pageRow . getValue ( pageField ) outPage = outDir + "\\" + pageName if pageName in exportList : arcpy . AddMessage ( "Exporting " + outPage ) if outFormat == "PNG" : arcpy . mapping . ExportToPNG ( mxd , outPage + ".png" , resolution = 300 ) if outFormat == "PDF" : arcpy . mapping . ExportToPDF ( mxd , outPage + ".pdf" , resolution = 300 ) if outFormat == "JPEG" : arcpy . mapping . ExportToJPEG ( mxd , outPage + ".jpg" , resolution = 300 )
The source code of the tool.
The source code of the tool .
"""The source code of the tool.""" # open mxd for reading # loop through list of pages
self
parameters
messages