More

Removing newline from AddMessage() with ArcPy

Removing newline from AddMessage() with ArcPy


I am looking for a way to add text in the same line in the progress dialog box. The AddMessage() adds a newline and this is not convenient.

For example: I want to have one line with the text:

arcpy.AddMessage("Sorting data… Done")

where "Sorting data… " should appear before the execution of the tool and "Done" after it.

Is there a way to do this?


I do not think that this can be done, and have never come across a requirement for it.

My only thought was to try a backspace () so I tried the code below behind a Python script tool:

import arcpy arcpy.AddMessage("Doing something… ") arcpy.AddMessage ("Done")

When I ran it this is what appeared in the tool results dialog:


I generally use something like this below (if I understand your question correctly)

import arcpy arcpy.AddMessage("Sorting data") # code to sort data… arcpy.AddMessage("Done")

This is an example from code I have used previously:

arcpy.AddMessage("… Sorting chainages based on distance") arcpy.Sort_management(Chainage_FC_Tempv2,chainage_FeatureClass, [["POINT_M", "ASCENDING"]]) arcpy.AddMessage("… Finished sorting chainages")

Watch the video: GIS Tools: ArcMapArcGIS Tool for counting inside features. points