importDocument does not work on some specific mxd. Manual import works fine in the app

433
1
05-11-2020 01:36 AM
WarrenCarey
New Contributor

Just wondering if anyone has experienced similar issue. I have a script that imports each 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 does not work for 30% of my mxd files. The script is just stuck at the importDocument statement for those specific mxd, nothing happens, no error thrown.

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

...

print(mxd_path)

aprx.importDocument(mxd_path)

print('imported')

...

Whenever the script reaches an troublesome mxd, I get its path printed, then nothing happens (have left it just like that for an hour). 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.

1 Reply
JTLancer
New Contributor II

I am experiencing this same problem.  Did you ever find a solution?  

It is frustrating as it is the final step in my code.  Using the arcpy.mapping method in python 2.7 works just fine on all my mxds, but I'm trying to use the arcpy.mp in python 3 and it keeps hanging.  

Unfortunately it doesn't seem that there is any way to get the properties of an mxd without first importing it.

My ideas for a workaround is to somehow

1.put a timer on the loop that will skip over an mxd after trying for a certain amount of time. 

2. try to call my python 2.7 script to run and ouptut the mxd properties to excel or csv and import that output into my py 3 script.

 

0 Kudos