1

I have a script that imports every MXD in a folder to an empty ArcGIS Pro project, then use saveACopy to save to a new project file. The problem is: The script just stops working every several MXD. Nothing happens, no error thrown.

For debugging, I got 2 print statements, one immediately before, one immediately after importDocument statement:

print(mxd_path)

aprx.importDocument(mxd_path)

print('imported')

Whenever the script reached a troublesome MXD, I got its path printed (the path looks totally normal to me), then nothing happened (have left it just like that for an hour). I've tried to import just that troublesome MXD with the script and got the same result: just the path printed, then nothing happened.

When I open the ArcGIS Pro app and import the manual way, i.e. right-click on the mxd file in Catalog pane and select Import and Open, the same troublesome MXD is imported and opened in seconds.

For MXD that can be imported via the script, it's done in less than one second.

MXD files are located in local hard drive. MXD file names contain A-Z character and dot. I've tried removing the dot from the file name of the troublesome MXD and that did not help.


The good news: When I opened the troublesome MXD in ArcMap application, saved it without doing anything, then re-run the script, that MXD was imported in less than one second. That means opening the MXD in ArcMap, then just save it will solve the issue.

The bad news: the way ArcPy opens and saves map Document is different from the way ArcMap application does. So using a script to open and save (or saveACopy) does not solve the problem.

11
  • 1
    Maybe it is something related to the file name like invalid characters, or unrecognized characters, or character encoding. Could you please check that?
    – ahmadhanb
    May 18, 2020 at 3:45
  • 1
    How many files are you trying to import?
    – ahmadhanb
    May 18, 2020 at 3:53
  • 1
    I think, it is better to update the question with the new information in the comments. One final thing, try to remove the dot within the file name, not that related to the extension, close the python ide software, re-open it again, and run the code with only that troublesome file. What will happen?
    – ahmadhanb
    May 18, 2020 at 4:02
  • 1
    More information on the nature of the data sources would be useful. Connection to an unroutable network addresses in an Enterprise geodatabase source would explain this issue.
    – Vince
    May 18, 2020 at 4:21
  • 1
    Not the MXDs, the sources to which they point. As an edit to the question.
    – Vince
    May 18, 2020 at 4:55

1 Answer 1

1

Found a work-around for this issue. A summary of possible solutions is below:

  • The manual way: open the troublesome MXD in ArcMap application, then just save it.

  • With Python script: access MXD and use saveACopy with specific version of the new MXD. In my case (ArcMap 10.6), all MXD files have been saved to ArcMap 10.3 (no idea why 10.4 and 10.5 are not supported. Maybe these versions are the cause of this issue).

Note that save and saveACopy without a version value will not work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.