MapExportTools.py
def execute(self, parameters, messages):
        """The source code of the tool."""
        # get necessary input parameters
        if parameters[0].value is True:
            mxdFile = "CURRENT"
        else:
            mxdFile = parameters[1].valueAsText

        outLocation = parameters[2].valueAsText
        exportList = parameters[3].valueAsText
        exportLayout = parameters[4].value
        outputW = parameters[5].value
        outputH = parameters[6].value
        outFormat = parameters[7].valueAsText

        mxd = arcpy.mapping.MapDocument(mxdFile)
        df = arcpy.mapping.ListDataFrames(mxd, "")[0]
        bkmkList = arcpy.mapping.ListBookmarks(mxd, "", df)

        for bkmk in bkmkList:
            df.extent = bkmk.extent
            if bkmk.name in exportList:
                if outFormat == "PDF":
                    outFile = outLocation + "\\" + bkmk.name + ".pdf"
                    arcpy.AddMessage("Exporting " + outFile)
                    arcpy.GetMessage(0)
                    if exportLayout is False:
                        arcpy.mapping.ExportToPDF(mxd, outFile, df, df_export_width=outputW * 300, df_export_height=outputH * 300, resolution=300)
                    else:
                        arcpy.mapping.ExportToPDF(mxd, outFile, resolution=300)
                elif outFormat == "PNG":
                    outFile = outLocation + "\\" + bkmk.name + ".png"
                    arcpy.AddMessage("Exporting " + outFile)
                    arcpy.GetMessage(0)
                    if exportLayout is False:
                        arcpy.mapping.ExportToPNG(mxd, outFile, df, df_export_width=outputW * 300, df_export_height=outputH * 300, resolution=300)
                    else:
                        arcpy.mapping.ExportToPNG(mxd, outFile, resolution=300)
                elif outFormat == "JPEG":
                    outFile = outLocation + "\\" + bkmk.name + ".jpeg"
                    arcpy.AddMessage("Exporting " + outFile)
                    arcpy.GetMessage(0)
                    if exportLayout is False:
                        arcpy.mapping.ExportToJPEG(mxd, outFile, df, df_export_width=outputW * 300, df_export_height=outputH * 300, resolution=300)
                    else:
                        arcpy.mapping.ExportToJPEG(mxd, outFile, resolution=300)
        return
The source code of the tool.
The source code of the tool.
The source code of the tool .
def execute(self, parameters, messages):
        if parameters[0].value is True:
            mxdFile = "CURRENT"
        else:
            mxdFile = parameters[1].valueAsText
        outLocation = parameters[2].valueAsText
        exportList = parameters[3].valueAsText
        exportLayout = parameters[4].value
        outputW = parameters[5].value
        outputH = parameters[6].value
        outFormat = parameters[7].valueAsText
        mxd = arcpy.mapping.MapDocument(mxdFile)
        df = arcpy.mapping.ListDataFrames(mxd, "")[0]
        bkmkList = arcpy.mapping.ListBookmarks(mxd, "", df)
        for bkmk in bkmkList:
            df.extent = bkmk.extent
            if bkmk.name in exportList:
                if outFormat == "PDF":
                    outFile = outLocation + "\\" + bkmk.name + ".pdf"
                    arcpy.AddMessage("Exporting " + outFile)
                    arcpy.GetMessage(0)
                    if exportLayout is False:
                        arcpy.mapping.ExportToPDF(mxd, outFile, df, df_export_width=outputW * 300, df_export_height=outputH * 300, resolution=300)
                    else:
                        arcpy.mapping.ExportToPDF(mxd, outFile, resolution=300)
                elif outFormat == "PNG":
                    outFile = outLocation + "\\" + bkmk.name + ".png"
                    arcpy.AddMessage("Exporting " + outFile)
                    arcpy.GetMessage(0)
                    if exportLayout is False:
                        arcpy.mapping.ExportToPNG(mxd, outFile, df, df_export_width=outputW * 300, df_export_height=outputH * 300, resolution=300)
                    else:
                        arcpy.mapping.ExportToPNG(mxd, outFile, resolution=300)
                elif outFormat == "JPEG":
                    outFile = outLocation + "\\" + bkmk.name + ".jpeg"
                    arcpy.AddMessage("Exporting " + outFile)
                    arcpy.GetMessage(0)
                    if exportLayout is False:
                        arcpy.mapping.ExportToJPEG(mxd, outFile, df, df_export_width=outputW * 300, df_export_height=outputH * 300, resolution=300)
                    else:
                        arcpy.mapping.ExportToJPEG(mxd, outFile, resolution=300)
        return
def execute ( self , parameters , messages ) : if parameters [ 0 ] . value is True : mxdFile = "CURRENT" else : mxdFile = parameters [ 1 ] . valueAsText outLocation = parameters [ 2 ] . valueAsText exportList = parameters [ 3 ] . valueAsText exportLayout = parameters [ 4 ] . value outputW = parameters [ 5 ] . value outputH = parameters [ 6 ] . value outFormat = parameters [ 7 ] . valueAsText mxd = arcpy . mapping . MapDocument ( mxdFile ) df = arcpy . mapping . ListDataFrames ( mxd , "" ) [ 0 ] bkmkList = arcpy . mapping . ListBookmarks ( mxd , "" , df ) for bkmk in bkmkList : df . extent = bkmk . extent if bkmk . name in exportList : if outFormat == "PDF" : outFile = outLocation + "\\" + bkmk . name + ".pdf" arcpy . AddMessage ( "Exporting " + outFile ) arcpy . GetMessage ( 0 ) if exportLayout is False : arcpy . mapping . ExportToPDF ( mxd , outFile , df , df_export_width = outputW * 300 , df_export_height = outputH * 300 , resolution = 300 ) else : arcpy . mapping . ExportToPDF ( mxd , outFile , resolution = 300 ) elif outFormat == "PNG" : outFile = outLocation + "\\" + bkmk . name + ".png" arcpy . AddMessage ( "Exporting " + outFile ) arcpy . GetMessage ( 0 ) if exportLayout is False : arcpy . mapping . ExportToPNG ( mxd , outFile , df , df_export_width = outputW * 300 , df_export_height = outputH * 300 , resolution = 300 ) else : arcpy . mapping . ExportToPNG ( mxd , outFile , resolution = 300 ) elif outFormat == "JPEG" : outFile = outLocation + "\\" + bkmk . name + ".jpeg" arcpy . AddMessage ( "Exporting " + outFile ) arcpy . GetMessage ( 0 ) if exportLayout is False : arcpy . mapping . ExportToJPEG ( mxd , outFile , df , df_export_width = outputW * 300 , df_export_height = outputH * 300 , resolution = 300 ) else : arcpy . mapping . ExportToJPEG ( mxd , outFile , resolution = 300 ) return
The source code of the tool.
The source code of the tool .
"""The source code of the tool.""" # get necessary input parameters
self
parameters
messages