Arcpy. Getmessages Returns Empty

Arcpy. Getmessages Returns Empty

I am trying to access the messages that was logged throughout a script.

arcpy.AddMessage("Something...")
message = arcpy.GetMessages()
print message  # always empty

The above is always empty.

According to the documentation [

Creates a geoprocessing informative message (Severity=0) that can be accessed with any of the GetMessages functions.

Anyone have experience with arcpy know what the deal is?

6

1 Answer

arcpy.GetMessages() returns the messages from the last geoprocessing tool. If you run two tools and then call arcpy.GetMessages(), you will only get the messages from the second tool.

AddMessage is not a geoprocessing tool, so it will have no effects on GetMessages.

Basically, if you want to get all the messages from an entire script, you will have to call arcpy.GetMessages() after every geoprocessing tool call.

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.

Elena Rostova
Author

Elena Rostova

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.