AnsweredAssumed Answered

How to implement dynamic input and output in Python script

Question asked by qwerty@ on Jul 30, 2015
Latest reply on Jul 30, 2015 by wwmiller68

I am trying to apply dynamic input and output in my Python script using arcpy.GetParameterasText, but I have an error:


Traceback (most recent call last):

  File "C:\", line 51, in <module>

    outWorkspace = arcpy.GetParameterAsText(2)

  File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\", line 648, in GetParameterAsText

    return gp.getParameterAsText(index)

  File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\geoprocessing\", line 224, in getParameterAsText

    self._gp.GetParameterAsText(*gp_fixargs(args, True)))

RuntimeError: Object: Error in getting parameter as text

Failed to execute (testing).


I defined my input and output as follow:


# Set the input workspace

arcpy.env.workspace = arcpy.GetParameterAsText(0)

# Set the input data

inRaster = arcpy.GetParameterAsText(1)

# Set the output workspace

outWorkspace = arcpy.GetParameterAsText(2)


What is wrong in my code? Why it cannot read the output workspace?