dosbourne

custom geoprocessing tool error

Discussion created by dosbourne on May 20, 2013
Latest reply on May 20, 2013 by curtvprice
Trying to complete a python tutorial that shows how to make custom tools.  I run the code below and it still produces an error message stating that "cur" is not defined.  I've experimented with the indentation, but still doesn't seem to run.  It appears that the problem is after "finally", the 'del cur' statement keeps the script from executing right.

import arcpy, os
try:
    outputFC = arcpy.GetParametersAsText(0)
    fClassTemaplate = arcpy.GetParametersAsText(1)
    f = open(arcpy.GetParameterAsText(2),'r')
    arcpy.CreateFeatureclass_management(os.path.split(outputFC)[0], os.path.split(outputFC[1]), "point", fClassTemplate)
    lstFires = f.readlines()
    cur = arcpy.InsertCursor(outputFC)
    cntr = 1
    for fire in lstFires:
        if 'Latitude' in fire:
            continue
        vals = fire.split(",")
        latitude = float(vals[0])
        longitude = float(vals[1])
        confid = int(vals[2])
        pnt = arcpy.Point(longitude, latitude)
        feat = cur.newRow()
        feat.shape = pnt
        feat.setValue("CONFIDENCEVALUE", confid)
        cur.insertRow(feat)
        arcpy.AddMessage("Record number" + str(cntr) + "written to feature class")
        cntr = cntr + 1
except:
    print arcpy.GetMessages()
finally:
    del cur
    f.close()

Outcomes