GetParameterAsText throws 'function' object is not subscriptable

513
1
Jump to solution
05-03-2021 04:43 PM
KathleenHoenke
Occasional Contributor

I have a script that I am adding into a model builder model. When I run the script without parameters, it runs fine. When I run it within the model with a parameter, it gives the error:  

 

Traceback (most recent call last):
File "E:\LiDar_experiments\culvertElevation.py", line 14, in <module>
culverts = arcpy.GetParameterAsText[0]
TypeError: 'function' object is not subscriptable

 

 

culverts = arcpy.GetParameterAsText[0]
DEM = arcpy.GetParameterAsText[1]
outpath = arcpy.GetParameterAsText[2]

arcpy.management.FeatureVerticesToPoints(culverts, os.path.join(outpath,"culverts_start"), "START")
arcpy.management.FeatureVerticesToPoints(culverts, os.path.join(outpath,"culverts_end"), "END")
arcpy.sa.ExtractValuesToPoints("culverts_start", DEM, os.path.join(outpath,"culverts_start_elevation"), "NONE", "VALUE_ONLY")
arcpy.sa.ExtractValuesToPoints("culverts_end", DEM, os.path.join(outpath,"culverts_end_elevation"), "NONE", "VALUE_ONLY")

 

 

0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

( ) not [ ]

GetParameterAsText—ArcGIS Pro | Documentation

round brackets

culverts = arcpy.GetParameterAsText[0]  # no

culverts = arcpy.GetParameterAsText(0)  # yes

 

In short functions use round brackets.  square ones are used when you want to subscript something like a list.


... sort of retired...

View solution in original post

0 Kudos
1 Reply
DanPatterson
MVP Esteemed Contributor

( ) not [ ]

GetParameterAsText—ArcGIS Pro | Documentation

round brackets

culverts = arcpy.GetParameterAsText[0]  # no

culverts = arcpy.GetParameterAsText(0)  # yes

 

In short functions use round brackets.  square ones are used when you want to subscript something like a list.


... sort of retired...
0 Kudos