Select to view content in your preferred language

Tool Not Working ....

1948
5
11-29-2019 03:34 AM
ShubhamBhatia
Emerging Contributor

For some work i was creating a tool which can add same field in attribute table of multiple feature classes. I wrote the script and it worked well but when i added this script to a tool; the tool didn't resulted in same results. I' m attaching screenshots for same. I'm kinda new to scripting and arcpy.

Tags (2)
0 Kudos
5 Replies
DanPatterson_Retired
MVP Emeritus

you need to use

GetParameterAsText—ArcPy Functions | ArcGIS Desktop 

so that the parameters are derived from the tool itself.

It is more fully described in

Adding a script tool—Geoprocessing and Python | ArcGIS Desktop 

The process is the same for ArcMap and ArcGIS Pro

0 Kudos
ShubhamBhatia
Emerging Contributor

I followed Dan Patterson your instructions but still it is getting failed .... your 

0 Kudos
DanPatterson_Retired
MVP Emeritus

Your toolbox shows that the tool is called "Script1" which means that you didn't associate your script "add.py" to the toolbox properly. hence the error message.  Notice that the path to your toolbox is called

E:\Toolbox.tbx#add.py"

You need to follow

What is a script tool?—Geoprocessing and Python | ArcGIS Desktop 

all the sections in here

Understanding script tool parameters—Geoprocessing and Python | ArcGIS Desktop 

and in here

Adding a script tool—Geoprocessing and Python | ArcGIS Desktop 

You will then get a properly formed and named toolbox with the script and its parameters correctly associated with the dialog.

0 Kudos
ShubhamBhatia
Emerging Contributor

It is still showing this error ....

0 Kudos
DanPatterson_Retired
MVP Emeritus

dump all the parameters except for 0 and 1 for now

It seems that your first parameter is a multivalue parameter which return a semicolon delimited list of shapefiles.  You will have to split that parameter on the semicolon and process each file in a 'for' loop.  in fact, it doesn't even appear as a parameter in your original script, it is defined as a workspace and not featureclass(es).

Why don't you just run the existing tool in batch mode? (or can't you do that in arcmap?  I can't remember)