Tool Not Working ....

175
5
11-29-2019 03:34 AM
Highlighted
New Contributor II

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)
Reply
0 Kudos
5 Replies
Highlighted
MVP Esteemed Contributor

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

Reply
0 Kudos
Highlighted
New Contributor II

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

Reply
0 Kudos
Highlighted
MVP Esteemed Contributor

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.

Reply
0 Kudos
Highlighted
New Contributor II

It is still showing this error ....

Reply
0 Kudos
Highlighted
MVP Esteemed Contributor

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)

Reply
0 Kudos