How to show standard foreground geoprocessing progress dialog?

3399
6
Jump to solution
07-28-2015 09:45 AM
GregMcQuat
New Contributor III

I am calling GPs by calling Geoprocessor.Execute("gpname", IVariantArray) but the only way I see to display a dialog is to create a new Progressor / StepProgressor and handle GP messages and update the dialog myself.

How can I just launch the standard dialog as though the user had filled in the all the info themselves and launched from the Application? Users like the message logging window which isn't part of the Progressor UI.

Thanks!

0 Kudos
1 Solution

Accepted Solutions
DuncanHornby
MVP Notable Contributor

Is this what you want? To call a geoprocessing tool and see its interface? This code is in VBA.

Public Sub OpenCalculateTool()
    ' Hook into Toolbox and get the tool
    Dim pUID As New UID
    pUID = "esriGeoprocessingUI.ArcToolboxExtension"
    Dim pArcToolboxExtension As IArcToolboxExtension
    Set pArcToolboxExtension = Application.FindExtensionByCLSID(pUID)
    Dim pArcToolbox As IArcToolbox
    Set pArcToolbox = pArcToolboxExtension.ArcToolbox
    Dim pGPTool As IGPTool
    Set pGPTool = pArcToolbox.GetToolbyNameString("CalculateField")

    ' Create messages, required by Invoke method
    Dim msgs As IGPMessages
    Set msgs = New GPMessages

    ' Get existing parameter structure
    Dim pArray As IArray
    Set pArray = pGPTool.ParameterInfo

    ' Declare Parameter interfaces
    Dim pGPParameter As IGPParameter
    Dim pGPDataType As IGPDataType
    Dim pGPParameterEdit As IGPParameterEdit

    ' Set the parameters of the tool
    Set pGPParameter = pArray.Element(0)
    Set pGPParameterEdit = pGPParameter
    Set pGPDataType = pGPParameter.DataType
    Set pGPParameterEdit.Value = pGPDataType.CreateValue("a") ' Featurelayer name
    Set pGPParameter = pArray.Element(1)
    Set pGPParameterEdit = pGPParameter
    Set pGPDataType = pGPParameter.DataType
    Set pGPParameterEdit.Value = pGPDataType.CreateValue("xx") ' Field
    Set pGPParameter = pArray.Element(3)
    Set pGPParameterEdit = pGPParameter
    Set pGPDataType = pGPParameter.DataType
    Set pGPParameterEdit.Value = pGPDataType.CreateValue("VB")

    ' Open the tool
    Dim pGPToolCommandHelper As IGPToolCommandHelper2
    Set pGPToolCommandHelper = New GPToolCommandHelper
    pGPToolCommandHelper.SetTool pGPTool
    pGPToolCommandHelper.InvokeModal 0, pArray, True, msgs
End Sub

View solution in original post

0 Kudos
6 Replies
FreddieGibson
Occasional Contributor III

Is this what you're trying to do?

Opening a geoprocessing tool's dialog box in .NET

http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#/Opening_a_geoprocessin...

The above workflow would present your user's with the GP Dialog and they'd have to fill in the needed parameters. I'm not sure if you're running this logic within ArcMap, Engine, or a console application, but I'd think that if you wanted to show a dialog that already has the parameters for the tool filled in you'd need to create your own tool window, wire into the geoprocessor events, and then run the gp tool in the background so that you could use the geoprocessor events to update your progressor that you're showing in your dialog.

Running a geoprocessing tool using background geoprocessing

http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/#/Running_a_geoprocessing_tool_usi...

0 Kudos
GregMcQuat
New Contributor III

Thanks, Freddie

It is the latter and I want to avoid creating the custom dialog and wiring of events. I've done this with the simple ProgressDialog but we lose the consistent ArcMap experience that we are trying to achieve.

This is in ArcMap. No problem opening the tool window but there we are trying to avoid having user's need to know all of the data paths and there are some config items that get pulled in as well. This is for a custom tool in a larger process and the users don't care about the details.

0 Kudos
DuncanHornby
MVP Notable Contributor

Is this what you want? To call a geoprocessing tool and see its interface? This code is in VBA.

Public Sub OpenCalculateTool()
    ' Hook into Toolbox and get the tool
    Dim pUID As New UID
    pUID = "esriGeoprocessingUI.ArcToolboxExtension"
    Dim pArcToolboxExtension As IArcToolboxExtension
    Set pArcToolboxExtension = Application.FindExtensionByCLSID(pUID)
    Dim pArcToolbox As IArcToolbox
    Set pArcToolbox = pArcToolboxExtension.ArcToolbox
    Dim pGPTool As IGPTool
    Set pGPTool = pArcToolbox.GetToolbyNameString("CalculateField")

    ' Create messages, required by Invoke method
    Dim msgs As IGPMessages
    Set msgs = New GPMessages

    ' Get existing parameter structure
    Dim pArray As IArray
    Set pArray = pGPTool.ParameterInfo

    ' Declare Parameter interfaces
    Dim pGPParameter As IGPParameter
    Dim pGPDataType As IGPDataType
    Dim pGPParameterEdit As IGPParameterEdit

    ' Set the parameters of the tool
    Set pGPParameter = pArray.Element(0)
    Set pGPParameterEdit = pGPParameter
    Set pGPDataType = pGPParameter.DataType
    Set pGPParameterEdit.Value = pGPDataType.CreateValue("a") ' Featurelayer name
    Set pGPParameter = pArray.Element(1)
    Set pGPParameterEdit = pGPParameter
    Set pGPDataType = pGPParameter.DataType
    Set pGPParameterEdit.Value = pGPDataType.CreateValue("xx") ' Field
    Set pGPParameter = pArray.Element(3)
    Set pGPParameterEdit = pGPParameter
    Set pGPDataType = pGPParameter.DataType
    Set pGPParameterEdit.Value = pGPDataType.CreateValue("VB")

    ' Open the tool
    Dim pGPToolCommandHelper As IGPToolCommandHelper2
    Set pGPToolCommandHelper = New GPToolCommandHelper
    pGPToolCommandHelper.SetTool pGPTool
    pGPToolCommandHelper.InvokeModal 0, pArray, True, msgs
End Sub
0 Kudos
FreddieGibson
Occasional Contributor III

I think the post from Duncan is what you're looking for. It does look like the call to InvokeModal will allow you specify the parameters for the tool prior to displaying the dialog. I've never tried this, but I'm definitely going to try this out on my end.

0 Kudos
GregMcQuat
New Contributor III

That's exactly what I was looking for! @Freddie - this does work; tried it out this morning.

I was just missing getting the IArray ParameterInfo and setting the parameters directly. I was previously passing in an IVariantArray and none of it would show up in the modal window.

I have the suspicion that we can also do this right through the Geoprocessor since there is a .SetValue and .GetValue that says it references the current tool but haven't figured that out yet.

Thanks so much for this!

0 Kudos
GregMcQuat
New Contributor III

Just a note: InvokeModal will always run in the foreground whereas Invoke will honour the Geoprocessing options for running in the background.