Execute a command in C#

2513
3
10-20-2016 02:09 PM
RichardDaniels
Occasional Contributor III

In the snippits gallery there is an example of executing a built in ArcGIS Pro command. Does anyone know where I can find the list of these commands?

Rich Daniels

---
IPlugInWrapper wrapper = FrameworkApplication.GetPlugInWrapper("esri_editing_ShowAttributes");
var command = wrapper as ICommand; // tool and command(Button) supports this

if ((command != null) && command.CanExecute(null))
  command.Execute(null);

0 Kudos
3 Replies
UmaHarano
Esri Regular Contributor

Hi Rich

You can see a list of all these commands on this page:  Button DAML ID Reference · Esri/arcgis-pro-sdk Wiki · GitHub 

Thanks

Uma Harano

ArcGIS Desktop SDK team

Wolf
by Esri Regular Contributor
Esri Regular Contributor

There is also the "Pro Generate DAML Id" utility described here: Arcgis Pro SDK for .Net utilities.  This utility allows generating a source file in your add-in project that contains DAML Ids for all plug-ins.  DAML ids are organized by type and the DAML Id string usually describes the purpose of the associated pug-in.  Once you generate a DAML Id source file, you can then reference the DAML Id through a constant using Visual Studio IntelliSense and avoid misspelled Ids.  This sample illustrates the DAML Id usage:  HookProCommands

RichardDaniels
Occasional Contributor III

To get some of the buttons/tools to work you need to programmatically activate the tab that the tool or button is on prior to executing. This is because the tool/button is disabled if the tab is not the  current tab. For example, the following activates the Analyst ribbon/tab:

FrameworkApplication.ActivateTab("esri_core_analysisTab");

If you are running a gp that is inside a group (vs. just a button) you may also need to 'run' the DAML Id of the group it is in.

IPlugInWrapper wrapper = FrameworkApplication.GetPlugInWrapper("esri_geoprocessing_analysisTools");
var command = wrapper as ICommand; // tool and command(Button) supports this

 

if ((command != null) && command.CanExecute(null))
  command.Execute(null);

then you can run the gp.

var param_values3 = Geoprocessing.MakeValueArray(null,null,"2 Miles");

//run the geoprocessing tool

Geoprocessing.OpenToolDialog("analysis.Buffer", param_values3);

0 Kudos