This document is archived and information here might be outdated.  Recommended version.


Custom geoprocessing function tools (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Extending ArcObjects > Custom geoprocessing function tools

Custom geoprocessing function tools


In this topic


About custom geoprocessing function tools

Creating a custom geoprocessing function tool extends the ArcGIS geoprocessing framework by using the ArcObjects components. This process gives you total control to develop a tool with the desired functionality. However, creating a custom geoprocessing function tool requires a complete understanding of the geoprocessing framework. For information on using geoprocessing tools in a .NET application, see Using geoprocessing.

Alternatives to creating a custom geoprocessing function tool

Before you create your own custom tool, consider the following alternatives:
  • Review the existing system tools. Your desired functionality may already be in an existing geoprocessing tool.
  • If your workflow can be accomplished using more than one existing tool, use ModelBuilder to chain the tools together.
  • Create a script tool using Python scripting. Python is a powerful scripting language, and most geoprocessing tasks can be done in Python. You can also programmatically customize tool behavior using Python.
  • Embed script tools in models created by ModelBuilder.
  • Write a stand-alone .NET application, and use the executable as the source of a script tool.
Script tools and model tools are custom tools, in that you create them using the ArcGIS Desktop graphical user interfaces (GUIs), such as wizards and ModelBuilder. Function tools are also custom tools, but they are created by extending the capabilities of ArcGIS Desktop. 

Creating a custom geoprocessing function tool 

There are, of course, scenarios for which you must create your own tool using ArcObjects. This requires implementing the IGPFunction2 and IGPFunctionFactory interfaces. The Building a custom geoprocessing function tool topic provides detailed information and examples. The following steps summarize the process:
  1. In a .NET application, create two classes (one will implement IGPFunction2 and the other will implement IGPFunctionFactory). You can create two separate files or keep them in a single file.
  2. Set the parameter properties (parameter type, direction, and acceptable values) in the ParameterInfo property of IGPFunction2.
  3. Leave the Validation method of IGPFunction2 as an empty stub - the geoprocessing framework automatically performs the validation.
  4. The Execute method of IGPFunction is the most important part of your tool. This is where you write your code to implement the specific algorithm.
  5. Implement IGPFunctionFactory. This makes your custom function tool accessible to users.
The custom function tool does not automatically become a part of ArcGIS. To use the tool, you need to complete a custom registration of the dynamic-link library (DLL) as follows:
  1. Use the ESRIRegAsm utility to register (and unregister) the DLL.
  2. Add the tool to a custom toolbox.
The tool is now ready to be used as any other geoprocessing tool.
Include the toolbox when you share the DLL. When you share the function DLL with someone, all they have to do is register the DLL, and the tool in the toolbox is ready to go. You do not have to register the DLL in the component category or add the tool to a toolbox.


See Also:

Using geoprocessing
Using geoprocessing to develop applications
How to create a script tool that runs an EXE
Building a custom geoprocessing function tool
ESRIRegAsm utility