Progress dialog with messages

1650
4
10-30-2019 09:01 AM
KarimD
by
New Contributor II

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 :

 

https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Geoprocessing#executing-a-tool-with-the-prog...

 

My problem, is that i also want to display arcpy messages (I use arcpy.AddMessage function).

 

Is there a way to achieve that ?

 

Thanks,

0 Kudos
4 Replies
NobbirAhmed
Esri Regular Contributor

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

0 Kudos
KarimD
by
New Contributor II

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,

0 Kudos
NobbirAhmed
Esri Regular Contributor

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:

https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Geoprocessing#executing-a-tool-with-the-prog...

Let us know if you successfully implement your objective.

0 Kudos
KarimD
by
New Contributor II

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,

0 Kudos