I encountered some problematic arcpy behavior when running this code. This code eventually creates an inventory of source data per layer used for each map contained in a directory (mxd_dir
).
# get list of all mxd filenames within directory to inventory
mxd_list = os.path.listdir(mxd_dir)
# list of full file path
fp_mxd_list = [os.path.join(mxd_dir, mxd) for mxd in mxd_list]
# get mxd_obj
for fp_mxd in fp_mxd_list:
mxd_obj = arcpy.mapping.MapDocument(fp_mxd)
# HERE IS WHERE ARCPY EXITS PYTHON
arcpy.mapping.ListLayers(mxd)
Arcpy is breaking from the Python script without throwing an exception/error or any indication of what failed - Python interpreter simply quits. This is occurring with arcpy.mapping.ListLayers
on a particular mxd. The file is not open anywhere, conforms with file naming conventions for the other files, no broken file paths.
I am not sure why arcpy does not print an exception statement to help diagnose failure.
Note: since posting I have determined that it was CAD data used within an MXD causing the issue, so it should be mentioned that the problematic mxd file contains CAD data. I have addressed the CAD issue in the comments essentially as the solution.
ArcMap 10.6, Windows 64 bit.