Generate Tool

This tool transforms a Python code sample or natural language prompt into a fully functional, documented, and parameterized Python toolbox (.pyt) file. It's perfect for rapidly prototyping custom ArcGIS tools or converting standalone scripts into reusable toolbox tools.

Overview

The Generate Tool is an advanced feature that automatically converts either raw Python code or natural language descriptions into complete ArcGIS Python Toolbox (.pyt) files. This tool streamlines the process of creating custom ArcGIS tools by handling all the boilerplate code, parameter inference, and proper toolbox structure.

Usage

  1. Open ArcGIS Pro and add the .pyt toolbox if you haven't already.
  2. Open the Generate Tool tool.
  3. Choose your input type: either provide existing Python code or a natural language description.
  4. Configure the toolbox name, tool name, and output location.
  5. Optionally enable Advanced Mode to customize parameter definitions.
  6. Click Run. The tool will generate a complete .pyt file ready for use in ArcGIS Pro.

Parameters

NameTypeRequiredDescription
SourceString (Choice)YesAI provider to use (OpenAI, Azure OpenAI, Claude, DeepSeek, Local LLM).
ModelStringNoThe AI model to use. Choices depend on the selected source.
EndpointStringNoCustom endpoint for Azure or local models (if applicable).
Deployment NameStringNoDeployment name for Azure OpenAI (if applicable).
Input TypeString (Choice)YesChoose between "Natural Language Prompt" or "Python Code" as your input method.
Python CodeString (Multiline)NoPaste your existing Python code here when "Python Code" is selected as input type. This code will be converted into a toolbox format.
Natural Language PromptStringNoDescribe the tool you want to create when "Natural Language Prompt" is selected. Be specific about functionality and parameters needed.
Toolbox NameStringYesName for the generated toolbox. Should be alphanumeric for best compatibility.
Tool NameStringYesName for the generated tool class. Should be alphanumeric for best compatibility.
Output PathFolderYesDirectory where the .pyt file will be saved. Defaults to the current project's home folder.
Advanced ModeBooleanNoEnable to access advanced parameter definition options. When enabled, you can provide custom parameter structures.
Parameter Definition (JSON)String (Multiline)NoJSON definition of custom parameters for the tool. Only available when Advanced Mode is enabled. Use this to specify exact parameter types, names, and properties.
Output ToolboxFileDerivedPath to the generated .pyt toolbox file.

How It Works

  1. Input Processing: If you provide a natural language prompt, the tool first generates Python code using the selected AI model. If you provide existing Python code, it uses that directly.
  2. Parameter Inference: The AI analyzes your code to automatically infer appropriate parameters, data types, and tool structure.
  3. Toolbox Generation: A complete .pyt file is generated with all required methods (getParameterInfo, execute, etc.) and proper ArcGIS toolbox structure.
  4. Validation: The generated toolbox is validated for syntax errors and compatibility.

Tips

Example Use Cases

Advanced Parameter Definition

When Advanced Mode is enabled, you can provide a JSON structure to precisely define tool parameters. Here's an example:

{
  "parameters": [
    {
      "name": "input_layer",
      "displayName": "Input Feature Layer", 
      "datatype": "GPFeatureLayer",
      "parameterType": "Required",
      "direction": "Input"
    },
    {
      "name": "buffer_distance",
      "displayName": "Buffer Distance",
      "datatype": "GPLinearUnit", 
      "parameterType": "Required",
      "direction": "Input"
    },
    {
      "name": "output_layer",
      "displayName": "Output Feature Layer",
      "datatype": "GPFeatureLayer",
      "parameterType": "Required", 
      "direction": "Output"
    }
  ]
}

Data Privacy Caution

Important: This tool sends your code or prompts to the AI provider you specify. Be mindful of your organization's data policies before sharing potentially sensitive information or proprietary code. Avoid including confidential algorithms, API keys, or sensitive business logic when using non-local model options.