2

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.

enter image description here

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.

enter image description here

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

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 Nov 23 '17 at 0:28
  • That's what I would try. – PolyGeo Nov 23 '17 at 1:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.