Model works, python script doesn't

Discussion created by jrhp@gmx.com on Apr 16, 2011
Latest reply on Apr 19, 2011 by DuncanRager
Hi there,

This is a very simple model to add a field using two parameters.
When I export it to a python script it doesn't work..

Don't think I'm setting up the script incorrectly.. I'm new to programming, so any help would be much appreciated.

I'm going to attempt to loop it to add six fields at once, also checking if the predetermined field names already exist or not. If anyone has done this before, or has a script for it that would be awesome!



exported .py script below..

# ---------------------------------------------------------------------------
# addfieldsv7.py
# Created on: Sun Apr 17 2011 09:36:55 a.m.
#   (generated by ArcGIS/ModelBuilder)
# Usage: addfieldsv7 <Field_Name> <Input_Table> 
# ---------------------------------------------------------------------------

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

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

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

# Script arguments...
Field_Name = sys.argv[1]

Input_Table = sys.argv[2]

# Local variables...
Output_Feature_Class = ""

# Process: Add Field...
gp.AddField_management(Input_Table, Field_Name, "LONG", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")