Is there any way to capture ArcMap Drawing Errors inside of a Python script?
Through Python, I would like to iterate through each layer inside of an MXD, make the layer visible, refresh the table of contents and the active view. I then want to see if any of these layers cause a drawing error, in which case I can write the layer that caused the drawing error to a log file so that I can later review and fix the problem causing the drawing errors. The only problem is I have no idea of how to capture the message from the ArcMap Drawing Error Dialog with Python. I do not particularly care what the error message is, I just want to see if an error is generated.
Example of an ArcMap Drawing Errors Dialog:
Arc Map Drawing Error Example
Another example where the GP finishes without error/exception but an ArcMap Drawing Error pop-up occurs.
arcpy.MakeMosaicLayer_management(
in_mosaic_dataset="//server/share//data.gdb/MOSAIC1",
out_mosaic_layer="MOSAIC1_lyr"
)
-
1I would run Check Geometry on each feature class. You can query the output tables, looking for Null Geometry, Unclosed rings, etc.klewis– klewis2016年02月10日 17:18:54 +00:00Commented Feb 10, 2016 at 17:18
-
Have you tried wrapping the script in a try except statement and seeing what error messages you capture when you refresh the active map?RHB– RHB2016年02月11日 02:09:32 +00:00Commented Feb 11, 2016 at 2:09
-
The script runs fine, there are no exceptions to catch (I tried that). It is also not a geometry problem, it is labeling problem. I spoke with ESRI, and they said there is no way to capture the ArcMap Drawing Errors with Python, which I think is unfortunate. Generally speaking, the errors that I am encountering all relate to a label expression referencing a field that no longer exists or was renamed. I should be able to parse the label expression instead and compare that info with the fields to see if there is a mismatch that way.cvandenberg– cvandenberg2016年02月11日 13:31:00 +00:00Commented Feb 11, 2016 at 13:31
1 Answer 1
Instead of trying to use ArcPy to do this I think you should see whether MXDPERFSTAT gives you the results that you want:
An ArcGIS Engine command line tool to diagnose typical mxd performance problems. Supports ArcGIS 9.3, 10, 10.1, 10.2, 10.3, 10.4 versions.
-
And if MXDPERFSTAT works you could run the command line argument via Python. janakiev.com/blog/python-shell-commandsGBG– GBG2021年09月22日 18:27:27 +00:00Commented Sep 22, 2021 at 18:27
Explore related questions
See similar questions with these tags.