Just what I was looking for. I was also trying to print a message in Calculate Value using
arcpy.AddMessage(message)
This works perfectly. I created a script tool using your code and making the severity a drop down list.
raise arcpy.ExecuteError("This input argument is weak")
import arcpy message = arcpy.GetParameterAsText(0) severity = arcpy.GetParameterAsText(1) arcpy.SetParameter(2, True) # Output parameter set to false on error if severity.upper() == "ERROR": arcpy.SetParameter(2, False) # error, don't continue arcpy.AddError(message) if severity.upper() == "WARNING": arcpy.AddWarning(message) if severity.upper() == "INFORM": arcpy.AddMessage(message)
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.