TransWikia.com

arcpy.importDocument of ArcGIS Pro not working on specific MXD and not throwing error

Geographic Information Systems Asked on August 25, 2021

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.

One Answer

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.

Answered by Kevin on August 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP