Select to view content in your preferred language

Problem with MultiValue MXD Parameter

776
5
01-20-2011 08:38 AM
JohnStephens
Regular Contributor
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:

<type 'exceptions.AssertionError'>: Invalid MXD filename.


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.
0 Kudos
5 Replies
deleted-user-1T_bOHag6M8d
Deactivated User
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.


John,

I'm now having very much the same problem. Although, my code did work once. It seems it failed to work every time since. Did you ever find a solution?

Thanks.
0 Kudos
NiklasNorrthon
Frequent Contributor
for map in mapList:
    print 'Map Document: %s' % map
    mxd = arcpy.mapping.MapDocument(map)


Then you get the name of the troublesome map document, which should help you solving your problem.
0 Kudos
MichaelFedak
Deactivated User
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 ' '.
0 Kudos
GroundHogg
Emerging Contributor
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 ' '.


Thanks, that solved my problem, the ' ' appended to the ends, took hours to figure out what was wrong.  Now I have to wonder why ESRI decided that apostrophes should be appended to string values.

Items directly from the TOC "do not exist" all because of the ' ' , I can understand if they were from some other location, but this is straight out of the TOC.

We are not amused ESRI...

(wheres the 'duh ESRI' smiley?)
0 Kudos
George_ChandeepCorea
Occasional Contributor
I wrote a script to create thumbnails of each mxd in a directory which works fine, but I want it to also walk through subdirectories - I am getting a Assertion Error (below). I've looked through the help but can't figure out whats wrong.

Code attached.

best,

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.
0 Kudos