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
- Open ArcGIS Pro and add the
.pyt
toolbox if you haven't already. - Open the Generate Tool tool.
- Choose your input type: either provide existing Python code or a natural language description.
- Configure the toolbox name, tool name, and output location.
- Optionally enable Advanced Mode to customize parameter definitions.
- Click Run. The tool will generate a complete .pyt file ready for use in ArcGIS Pro.
Parameters
Name | Type | Required | Description |
---|---|---|---|
Source | String (Choice) | Yes | AI provider to use (OpenAI, Azure OpenAI, Claude, DeepSeek, Local LLM). |
Model | String | No | The AI model to use. Choices depend on the selected source. |
Endpoint | String | No | Custom endpoint for Azure or local models (if applicable). |
Deployment Name | String | No | Deployment name for Azure OpenAI (if applicable). |
Input Type | String (Choice) | Yes | Choose between "Natural Language Prompt" or "Python Code" as your input method. |
Python Code | String (Multiline) | No | Paste your existing Python code here when "Python Code" is selected as input type. This code will be converted into a toolbox format. |
Natural Language Prompt | String | No | Describe the tool you want to create when "Natural Language Prompt" is selected. Be specific about functionality and parameters needed. |
Toolbox Name | String | Yes | Name for the generated toolbox. Should be alphanumeric for best compatibility. |
Tool Name | String | Yes | Name for the generated tool class. Should be alphanumeric for best compatibility. |
Output Path | Folder | Yes | Directory where the .pyt file will be saved. Defaults to the current project's home folder. |
Advanced Mode | Boolean | No | Enable to access advanced parameter definition options. When enabled, you can provide custom parameter structures. |
Parameter Definition (JSON) | String (Multiline) | No | JSON 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 Toolbox | File | Derived | Path to the generated .pyt toolbox file. |
How It Works
- 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.
- Parameter Inference: The AI analyzes your code to automatically infer appropriate parameters, data types, and tool structure.
- Toolbox Generation: A complete .pyt file is generated with all required methods (getParameterInfo, execute, etc.) and proper ArcGIS toolbox structure.
- Validation: The generated toolbox is validated for syntax errors and compatibility.
Tips
- Be specific in prompts: Include details about what inputs your tool should accept and what outputs it should produce.
- Use descriptive names: Choose clear, descriptive names for your toolbox and tool for better organization.
- Test the output: Always test the generated toolbox in ArcGIS Pro to ensure it works as expected.
- Advanced Mode: Use Advanced Mode when you need precise control over parameter types and properties.
- Iterative refinement: If the first attempt doesn't produce exactly what you need, try refining your prompt or code input.
Example Use Cases
- Script to Tool: Convert a standalone Python script that processes feature layers into a reusable toolbox tool.
- Custom Geoprocessing: Create tools for specialized analysis workflows specific to your organization.
- Automation Toolbox: Generate tools that automate repetitive GIS tasks with proper parameter validation.
- Data Processing: Create tools for custom data import, export, or transformation workflows.
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.