pevalent

Edit shapefile using modelbuilder

Discussion created by pevalent on Sep 9, 2013
Latest reply on Sep 11, 2013 by geomanscott
I have got the folloving problem:
I need to change some of the values of one attribute in my point shapefile. I want to do it in modelbuilder, but I dont know how. I have found a script which can do it in python. The script is as following:

import arcpy
... 
... features = arcpy.UpdateCursor(r"C:\Users\peter.valent\Documents\ArcGIS\Data\Vah po LM\test_points.shp")
... for feature in features:
...         feature.precipitation = value
...         features.updateRow(feature)
... del feature,features


This is what I put to modelbuilder:
Expression:
myfcn(r"%file_name%","%value%")

Code Block:
import arcpy

def myfcn(path,value):
features = arcpy.UpdateCursor(path)
for feature in features:
        feature.precipitation = value
        features.updateRow(feature)
del feature,features

Outcomes