Hello everybody,
I am in the middle of a project and I have a question regarding interactions between arcgis pro and Python.
I want to execute a tool with the progress dialog.
I already found the documentation for doing just that :
My problem, is that i also want to display arcpy messages (I use arcpy.AddMessage function).
Is there a way to achieve that ?
Thanks,
When you execute a gp tool you get back a result object:
var result = await Geoprocessing.ExecuteToolAsync(tool_path, ....)
The result object, among other information, contains the messages returned by the tool.
You can get them by Messages property as follows:
var messages = result.Messages
In our SDK (ArcGIS Pro 2.4 API Reference Guide ), if the link does not take you directly to IGPResult, browse to:
ArcGIS.Desktop.Core Assembly > Namespaces > ArcGIS.Desktop.Core.Geoprocessing > Interfaces > IGPResult > Members
Hi Nobbir Ahmed,
Thank you for your reply.
What you are describing is a way to display messages after the python geoprocessing script finishes (ProConcepts Geoprocessing · Esri/arcgis-pro-sdk Wiki · GitHub).
I am searching for a way to display the messages during their generation (ie. during the execution of the Python script), in "real time."
Ideally, they can be displayed in the process dialog which doesn't display that much currently.
Is there a way to do that ?
Thanks,
The python script works out-of-process when you call the script from within .Net SDK. Unfortunately, I don't know a way to get the messages in real-time
Here is an sample code that you can try with: it implements delegate and handle events (such as OnProgressMessage, OnProgressPos or OnValidate:
Let us know if you successfully implement your objective.
Hi Nobbir Ahmed,
Just to inform on how I handled the problem.
In the end, I couldn't find a way to get messages in real time, so I just added a logging system to my python script.
it is not worth the real time, but it allows for ex post analyzes.
Have a good day,