Select to view content in your preferred language

Setting Parameter in my Script Tool

1288
1
03-04-2022 01:19 PM
SteveKim1
Emerging Contributor

Hi Everyone,

I've made a script to add fields to all my feature classes inside a gdb. My issue is that I'm trying set my Parameters in my Script Tool so that a user can run the script on any gdb they input by setting the workspace with arcpy.GetParameterAsText(0)

import arcpy

arcpy.env.workspace = arcpy.GetParameterAsText(0)

fcList = arcpy.ListFeatureClasses()
for fc in fcList:
        arcpy.management.AddField(....) 
        arcpy.management.AddField(....)

 

Am I missing a step?

 

0 Kudos
1 Reply
DanPatterson
MVP Esteemed Contributor

Defining parameters in a Python toolbox—ArcGIS Pro | Documentation

way down towards the bottom

Workspace
The workspace filter specifies the types of input workspaces that are permissible. There are three values:

If you want to work with the custom toolboxes, they allow you to just pick the workspace parameter from a list

Setting script tool parameters—ArcGIS Pro | Documentation

same workspace parameter is also towards the bottom


... sort of retired...
0 Kudos