ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Framework Namespace / IPlugInWrapper Interface
Members Example

In This Topic
    IPlugInWrapper Interface
    In This Topic
    The public interface for DAML defined controls.
    Syntax
    Public Interface IPlugInWrapper 
    public interface IPlugInWrapper 
    Remarks
    Controls defined in DAML and added to the ribbon control are not directly accessible by other clients. Instead, 3rd parties can use FrameworkApplication.GetCommandWrapper to access a limited set of functionality such as updating a command's caption at run-time.
    Example
    Programmatically start Edit Annotation
    // programmatically activates the Edit Annotation tool by invoking the corresponding
    // plugin. The tool must be enabled for the operation to succeed.
    {
      var plugin = FrameworkApplication.GetPlugInWrapper("esri_editing_EditVerticesText");
      if (plugin.Enabled)
        ((ICommand)plugin).Execute(null);
    }
    Execute a command
    {
      IPlugInWrapper wrapper = FrameworkApplication.GetPlugInWrapper("esri_editing_ShowAttributes");
      // tool and command(Button) supports this
    
      if (wrapper is ICommand command && command.CanExecute(null))
        command.Execute(null);
    }
    Set the current tool
    {
      // use SetCurrentToolAsync with await
      FrameworkApplication.SetCurrentToolAsync("esri_mapping_selectByRectangleTool").Wait();
    
      // or use ICommand.Execute
      if (FrameworkApplication.GetPlugInWrapper("esri_mapping_selectByRectangleTool") is ICommand cmd && cmd.CanExecute(null))
        cmd.Execute(null);
    }
    Get the job Id associated with a running OpenProProjectItems step
    {
      // Get the job Id associated with a running OpenProItems step for a Pro Add-In module
    
      // In the Add-In Module class, override the ExecuteCommandArgs(string id) method and return a Func<Object[], Task> object like the sample below
      // Refer to the Workflow Manager ProConcepts Sample Code link for an example
    
      Func<object[], Task> overrideFunction = (args) => QueuedTask.Run(() =>
      {
        try
        {
          // Get the jobId property from the OpenProProjectItemsStep arguments and store it.
          OpenProProjectItemsStepCommandArgs stepArgs = (OpenProProjectItemsStepCommandArgs)args[0];
          var jobId = stepArgs.JobId;
          ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show($"Got job id from ProMappingStep args: {jobId}", "Project Info");
    
          // Run the command specified by the id passed into ExecuteCommandArgs
          IPlugInWrapper wrapper = FrameworkApplication.GetPlugInWrapper(id);
          if (wrapper is ICommand command && command.CanExecute(null))
            command.Execute(null);
        }
        catch (Exception e)
        {
          ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show($"ERROR: {e}", "Error running command");
        }
      });
    
      // Use overrideFunction to get the jobId from the step args when the command is executed
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also