I running a script using the Toolbox in ArcMap, and the script requires inputs to run. Most of these inputs such as file names and folders are pretty straight forward. However, some of the parameters the script uses are simple floating numeric values. The list of parameter types includes "Any Value", and "Long", but these do not work. "Long" requires an integer, and "Any Value seems to behave as though it is looking for a data set.
I can simply set the values in the script, but I want to be able to hand off this tool to folks who would use it in the Toolbox, rather than having to access the script directly. Thanks, and my apologies for what is likely a simple problem!
Solved! Go to Solution.
'Double' is the data type you need.
Are you retrieving your parameters in the toolbox using GetParameter or GetParameterAsText or sys.argv ?
You need to check what the toolbox returns which is usually a text representation of the parameter.
I have used some that you have mentioned and just perform the conversion in the script
x = GetParameterAsText(3) # parameter is defined as required, input with type Double
try:
x = float(x) # ensure inputs can be cast
.....
with the requisite check for errors on the humanware side.
Hi Dan, this sounds like a great solution, I have been using both the "arcpy.GetParameter" and the "arcpyGetParametersAsText". The GetParameter function has been useful and simple to use, as long as there is a Data Type that fits the data set well.
I will give this a try and let you know how it goes.
Cheers,
Robert
'Double' is the data type you need.
David Pike in the comments of my post
...input with type Double
This is excellent, thank you!
grief... someone else didn't read the comment line in the sample script