FLBB

Simple Geoprocessing Question

Discussion created by FLBB on Apr 6, 2014
Latest reply on Apr 7, 2014 by FLBB
I am new to building customized GP tools but I have made significant progress. And I have created a tool that adds a unique ID field and auto populates the added unique ID field incrementally, using the specified data theme abbreviation followed by the unique index.

Here is the code I am working with and error report; it does exactly what it's supposed to do when working with shapefiles but fails when processing feature classes?? Any help is greatly appreciated.

import arcpy
import os
fclist= arcpy.GetParameterAsText(0).split(";")
inputfield=arcpy.GetParameterAsText(1)
for fc in fclist:
        arcpy.AddField_management(fc,inputfield,"TEXT","","",20,"UniqueID","NULLABLE","NON_REQUIRED")
        count=0
        cursor=arcpy.UpdateCursor(fc)
        for row in cursor:
                count+=1
                newstr = str(count)
                row.setValue(inputfield,str.upper(str.split(os.path.basename(str(fc)),'_')[0])+newstr.zfill(6))
                cursor.updateRow(row)
        del cursor
        del row



Error:

Traceback (most recent call last):
   line 6, in <module>
    arcpy.AddField_management(fc,inputfield,"TEXT","","",20,"UniqueID","NULLABLE","NON_REQUIRED")
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Input Table: Dataset 'C:\test\Test.gdb\Categories' does not exist or is not supported
Failed to execute (AddField).

Outcomes