mapList = string.split(sys.argv[1],";")
<type 'exceptions.AssertionError'>: Invalid MXD filename.
for map in mapList: mxd = arcpy.mapping.MapDocument(map)
I have a script that is supposed to automate exporting several map documents. I have it set up as a script tool. The user is prompted to enter a few things, including several MXDs to be exported. I have handled those values as a list and used the 'split' function to separate them:mapList = string.split(sys.argv[1],";")
After that I have a loop that is supposed to loop through the above list and export the maps. However, when I run the script I get the error:
The top of the loop looks like this:for map in mapList: mxd = arcpy.mapping.MapDocument(map)
I know the rest of the code works, because if I take out the 'map' variable and directly enter the file path of an MXD the script works. I assume it is something blatantly simple, but I just can't figure it out. Any help would be appreciated.
for map in mapList: print 'Map Document: %s' % map mxd = arcpy.mapping.MapDocument(map)
I am having the same problem and I have tried to use multiple map documents to see if the name is the issue. It throws the same error every time. So why can't I get an mxd name from the value table containing full paths to mxd's?
Ok my problem occurred when I grabbed the values out of the table, they were delimited with ' '.
Reading mxd files from P:\2011\Job_031_TownPlanning_SeriesProduction\Working\mxd\B&L\2\Ver1 11 2\11_TownPlanning_B&L_Overlay_Ver2_Kuranda.mxd <geoprocessing Map object object at 0x15DE25E0> Created thumbnail for 2\10_TownPlanning_B&L_Overlay_Ver2_MtMalloy.mxd Traceback (most recent call last): File "P:\2011\Job_031_TownPlanning_SeriesProduction\Working\mxd\B&L\2\Ver1\MakeThumbnails-TB.py", line 25, in <module> mapDoc=arcpy.mapping.MapDocument(mapDocs) File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\arcobjects\mixins.py", line 443, in __init__ assert (os.path.isfile(mxd) or (mxd.lower() == "current")), gp.getIDMessage(89004, "Invalid MXD filename") AssertionError: Invalid MXD filename.