Select to view content in your preferred language

Error in getting parameter as text

3819
2
05-09-2014 02:19 AM
H_A_D_Padmasiri
Deactivated User
Dear sir

When I  try to run a python script. I cant get the parameter as text. the following error message is display when it run
This parameter is save from the calender.

Traceback (most recent call last):
  File "J:\Gampaha\Scripts\Creating_Building_New.py", line 13, in <module>
    VDate = arcpy.GetParameterAsText(4)
  File "c:\program files\arcgis\desktop10.1\arcpy\arcpy\__init__.py", line 592, in GetParameterAsText
    return gp.getParameterAsText(index)
  File "c:\program files\arcgis\desktop10.1\arcpy\arcpy\geoprocessing\_base.py", line 224, in getParameterAsText
    self._gp.GetParameterAsText(*gp_fixargs(args, True)))
RuntimeError: Object: Error in getting parameter as text

Thanks

Padmasiri
Tags (2)
0 Kudos
2 Replies
JoshuaChisholm
Frequent Contributor
Hello Padmasiri,

Thank seems strange. One suggestion, are you starting your list at 0? As in arcpy.GetParameterAsText(0) is the first text input and arcpy.GetParameterAsText(4) would be the fifth.

Alternatively you can try using sys.argv[]. It would look something like this:

import sys

input1=sys.argv[1] #Note that the list starts at 1 because sys.argv[0] stores the location of the current script.
input2=sys.argv[2]
input3=sys.argv[3]
input4=sys.argv[4]
input5=sys.argv[5] #the fifth input to the tool. Same as arcpy.GetParameterAsText(4)


Good luck!
0 Kudos
H_A_D_Padmasiri
Deactivated User
Hello Padmasiri,

Thank seems strange. One suggestion, are you starting your list at 0? As in arcpy.GetParameterAsText(0) is the first text input and arcpy.GetParameterAsText(4) would be the fifth.

Alternatively you can try using sys.argv[]. It would look something like this:

import sys

input1=sys.argv[1] #Note that the list starts at 1 because sys.argv[0] stores the location of the current script.
input2=sys.argv[2]
input3=sys.argv[3]
input4=sys.argv[4]
input5=sys.argv[5] #the fifth input to the tool. Same as arcpy.GetParameterAsText(4)


Good luck!


Dear sir

Thank you very much for your answer.

It run correctly when I amend according to you.

Thanks again

Padmasiri
0 Kudos