taylor65

Assertion error on ExportToPDF function.

Discussion created by taylor65 on Dec 15, 2011
Latest reply on Aug 3, 2012 by dmcconna
Hi, I'm new to ArcMapping with Python. For my first task I decided to do a batch export of maps. My code is simple but I get an error that has me stumped.

import arcpy, os
inpath="C:\\GIS\\MXD_dir\\"
outpath="C:\\Out_map_dir\\"
dirList = os.listdir(inpath)

arcpy.OverWriteOutput = 1

for item in dirList:
    print inpath + item
    arcpy.mapping.ExportToPDF(inpath + item, outpath + item[:-4] + ".pdf" )
    arcpy.mapping.ExportToJPEG(inpath + item, outpath + item[:-4] +".jpg" )



and here is my error...
Traceback (most recent call last):
  File "C:\GIS\Scripts\pdf_export.py", line 9, in <module>
    arcpy.mapping.ExportToPDF(inpath + item, outpath + item[:-4] + ".pdf" )
  File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\utils.py", line 179, in fn_
    return fn(*args, **kw)
  File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\mapping.py", line 790, in ExportToPDF
    assert isinstance(map_document, MapDocument)
AssertionError


Any help or insight would be appreciated. Thanks!

Outcomes