turnerkyle

GetParameterAsText(5) and above fails

Discussion created by turnerkyle on Oct 26, 2011
Latest reply on Oct 27, 2011 by turnerkyle
Hi all,

I have a simple script that adds some fields, prompts the user for the info to fill those fields, and populates them via fieldcalculator. However, if I try to use any user input (i.e. getParameterAsText) at or above the 6th parameter (i.e. getParameterAsText(5)) it fails. I get the following error: (see attached screenshot).

Here is the script:

# Import system modules
import arcpy, sys
from arcpy import env
 
# Set local variables
inFeatures = arcpy.GetParameterAsText(0)
 
name = arcpy.GetParameterAsText(1)
fieldName = name + 'IDPK'
fieldAlias = fieldName
arcpy.AddField_management(inFeatures, fieldName, "TEXT", "", "", 20, fieldAlias)
expression = "autoIncrement(arcpy.GetParameterAsText(2), arcpy.GetParameterAsText(3), !INSTLN_ID!)"
codeblock = """rec = 0
def autoIncrement(siteID, instalID, instlnID):
    global rec
    length = len(instlnID)
    if (length == 4):
        pStart = 1 
        pInterval = 1 
        if (rec == 0):
            rec = pStart
        else:
            rec = rec + pInterval 
 
        zeros = 15 - len(instalID) - len(siteID)
        return siteID + '_' + instalID + '0001' + str(rec).zfill(zeros)"""
 
# Execute CalculateField 
arcpy.CalculateField_management(inFeatures, fieldName, expression, "PYTHON", codeblock)
 
realPropertySiteUniqueID = arcpy.GetParameterAsText(4)
arcpy.AddField_management(inFeatures, "realPropertySiteUniqueID", "LONG")
arcpy.CalculateField_management(inFeatures, "realPropertySiteUniqueID", realPropertySiteUniqueID)
 
realPropertyUniqueID = arcpy.GetParameterAsText(5)
arcpy.AddField_management(inFeatures, "realPropertyUniqueID", "TEXT", "", "", 3, "realPropertyUniqueID")
arcpy.CalculateField_management(inFeatures, "realPropertyUniqueID", realPropertyUniqueID)
 
wacInnrCode = arcpy.GetParameterAsText(6)
arcpy.AddField_management(inFeatures, "wacInnrCode", "TEXT", "", "", 10, "wacInnrCode")
arcpy.CalculateField_management(inFeatures, "wacInnrCode", wacInnrCode)
 
owner = arcpy.GetParameterAsText(7)
arcpy.AddField_management(inFeatures, "owner", "TEXT", "", "", 4, "owner")
arcpy.CalculateField_management(inFeatures, "owner", owner)



Thank you for your time.
 
Arc 10 SP3
Windows 7

Attachments

Outcomes