kope967

interactive input of values during Python sript processing

Discussion created by kope967 on Oct 30, 2011
Latest reply on Oct 30, 2011 by lpinner
I need create script, where user will be interactively insert values. Script will have these processing steps:

1) select input file
2) do some calculations
3) type result of calculations to message window
4) user interactively input value based on results of steps 2 and 3
5) calculation continue

and script MUST be used as tool in ArcMap ToolBox.

For selection of input file I use gp.GetParameterAsText() function and it is ok. For input during script processing I try use raw_input function-it is work in command prompt, but when I use it as script added to toolbox, process is crashed and I get this error message:

<type 'exceptions.EOFError'>: EOF when reading a line

Can someone advise please ?

Example of my code:

import os, string, arcgisscripting, sys
gp=arcgisscripting.create(9.3)
##select input file
in_file=gp.GetParameterAsText(0)
##treshold=gp.GetParameterAsText(2)
##example of calculation
gp.MakeFeatureLayer(in_file, "in_file_lyr")
gp.SelectLayerByAttribute("in_file_lyr","NEW_SELECTION", "\"shape_area\">1500")
count=gp.GetCount_management("in_file_lyr")
##writing results to message window
gp.addMessage("Selected "+str(count))
##input treshold
tresh = raw_input('Please type treshold value: ')##do not work in toolbox, process is crashed in this row
##writing treshold to message window
gp.addMessage("Treshold is "+str(tresh))
##...
##computation continue

Thanks for help.
Miroslav

Outcomes