rsoper

Python script created in model builder does not work

Discussion created by rsoper on Jul 26, 2011
Latest reply on Aug 10, 2011 by smehta-esristaff
This simple calculate field script runs fine in model builder but does not run when converted to a python script. What is the problem?

# ---------------------------------------------------------------------------
# test.py
# Created on: Tue Jul 26 2011 10:59:41 AM
#   (generated by ArcGIS/ModelBuilder)
# ---------------------------------------------------------------------------

# Import system modules
import sys, string, os, arcgisscripting

# Create the Geoprocessor object
gp = arcgisscripting.create()

# Load required toolboxes...
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")


# Local variables...
parcel_shp = "C:\\assessor\\parcel.shp"
parcel_shp__2_ = "C:\\assessor\\parcel.shp"

# Process: Calculate Field...
gp.CalculateField_management(parcel_shp__2_, "per_sqft", "newval", "VB", "if ([LV_sqft] > 0) then\\n    newval = [bldgvalue] / [LV_sqft]\ \nelse\\n   newval = 0\\nend if")

Outcomes