I have a model (ModelBuilder) and within I added a python script to calculate a field. My problem now is, that I don't know how to make the output appear in my model as it is the same as the input (only with the field calculated).

I imagine there is a very simple way, but I am new to ModelBuilder and python and just can't think of it?

Alternatively, I could also try using the field calculator, but I would prefer it this way.

And here is my script:

import arcpy
from arcpy import env

env.workspace = arcpy.GetParametersAsText(0)  # the workspace
inLayer = arcpy.GetParameterAsText(1) # The shapefile
inField = arcpy.GetParameterAsText(2)  # The column in attr table with Area
outField = arcpy.GetParameterAsText(3) # The column in attr table which should be calculated

# Create a list from area field and find min & max value

listing = []
rows = arcpy.SearchCursor(inLayer)
for row in rows:
del rows

min = listing[0]
max = listing[-1]

# Calculate the normalized value

rows2 = arcpy.UpdateCursor(inLayer)
for row2 in rows2:
    row2.setValue(outField, (max - row2.getValue(inField))/(max - min))
del rows2

1 Answer 1


You'll want to add your script as a tool in a custom Toolbox, then add your script tool into your ModelBuilder process.

When you create your script tool, be sure to set the script tool parameters up so that you have the Type parameter set to "Derived" with the Direction parameter set to "Output".

  • Thanks for that answer. However, the problem is not fully solved. It seems to go in the right direction. However, I cannot use the Output as a new Input in modelbuilder - I guess because I have no output mentioned in my script. So my next question is how to change my script to make that work?
    – oddpodm
    Sep 10, 2013 at 9:02
  • I found the missing piece:
    – oddpodm
    Sep 10, 2013 at 9:44
  • Nothing had to be changed in the script. Only I had to set the Obtained from Parameter to Input. Then everything works as it should. So thanks again for the help!
    – oddpodm
    Sep 10, 2013 at 9:47
  • Glad I could help, @oddpodm. If this resulted in the info you need, please click the little "checkmark" next to my answer to close this question. Thanks. Sep 11, 2013 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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