I have a custom model (called TOOLNAME) in a custom toolbox developed in Model Builder on ArcGIS 10.1 Desktop. The model takes two input parameters (SingleFDI_D
and dayindex
) and outputs a Derived parameter called "MaxFDI_DateTime
" which is data of String type.
The model runs well within the ModelBuilder on ArcGIS Desktop. It returns the result MaxFDI_DateTeime: 22/11/2017 12:00:00 AM
as below.
I will need to run the model in Python.
How do I get the output of MaxFDI_DateTime out of the tool execution in Python?
arcpy.ImportToolbox(TOOL_DIR)
# The custom model should return a String, how to retrieve it here?
model_result = arcpy.{TOOLNAME}_{TOOLBOX_ALIAS}(SingleFDI_D, str(day))
1 Answer 1
In your code snippet model_result
is a Result object.
Without testing I think the string you are after can be printed from that using:
print(model_result.getOutput(0))
or
print(model_result[0])
-
Thanks! If the code snippet has multiple (i) output params, we could potentially use model_result.getOutput(i-1)?alextc– alextc2017年11月23日 00:28:12 +00:00Commented Nov 23, 2017 at 0:28
-
That's what I would try.2017年11月23日 01:02:19 +00:00Commented Nov 23, 2017 at 1:02
Explore related questions
See similar questions with these tags.