arcpy.GetParameterAsText(0) return tuple

811
6
Jump to solution
01-29-2021 12:05 PM
Labels (1)
MingHan
New Contributor III

Hi everyone 

    I tried to create a python script toolbox. I tried to obtain ArcGIS parameters using both arcpy.GetParameterAsText(0) and sys.argv[1].  

    I think I supposed to obtain a string. but I got a tuple. 

    Is there any reason why this happens?  My another tool works fine. 

    The variable I got is like this: 

     

['C:\\Users\\dustm\\Documents\\GitHub\\TurkeyLake_Project\\Shapefiles\\Shapefiles_to_define_HRUs\\finalcat_info.shp']
['#']
['abc']

Thanks 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
JoshuaBixby
MVP Esteemed Contributor

I did a quick check/test running a script tool from within Pro, and I don't see this behavior for either single-value or multi-value input.  Maybe it is how you are setting or passing the arguments, can you elaborate on how the shape file is getting passed to the script?

And, are you using the latest version of Pro?

View solution in original post

6 Replies
DanPatterson
MVP Esteemed Contributor

you got a list, is by chance your parameter multivalue?

perhaps you should show the actual code and parameter definitions


... sort of retired...
MingHan
New Contributor III

MingHan_0-1611955068318.png

Here is all my parameter definitions, there is no multi value. 

0 Kudos
DanPatterson
MVP Esteemed Contributor

you apparently have 19 parameters.... which is the parameter in question?   You need to scroll to the right to see if the multivalue option is specified.

Also, if your getparameterastext is all of them, that is why it returns a list. 


... sort of retired...
MingHan
New Contributor III

MingHan_0-1611956939866.png

this is printed one parameter using   arcpy.GetParameterAsText(0) . 

['C:\\Users\\dustm\\Documents\\GitHub\\TurkeyLake_Project\\Shapefiles\\Shapefiles_to_define_HRUs\\finalcat_info.shp']

 

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

I did a quick check/test running a script tool from within Pro, and I don't see this behavior for either single-value or multi-value input.  Maybe it is how you are setting or passing the arguments, can you elaborate on how the shape file is getting passed to the script?

And, are you using the latest version of Pro?

MingHan
New Contributor III

Hi everyone  

    I figure it out, it is because I add a , after each parameter assignment. 

Thanks for all your help 

Ming 

0 Kudos