model built with vb code does not work as exported to python script

333
1
06-23-2011 04:40 AM
RobertSoper
New Contributor
Hi, I'm new to python. I created a model using vb with model builder and it works fine. When I exported it as a python script it does not perform it's function. This is the Code:
# ---------------------------------------------------------------------------
# test.py
# Created on: Tue Jun 21 2011 03:36:21 PM
#   (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:\\PVAShp\\parcel.shp"
parcel_shp__2_ = "C:\\PVAShp\\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")

can anyone tell me what is wrong or how it should be written in python?
Thanks
Bob
Tags (2)
0 Kudos
1 Reply
JasonScheirer
Occasional Contributor III
Replace each \\n with \n in the code. I believe this was fixed in 10.0.
0 Kudos