gp.InsertCursor method (ArcGIS 9.3)

Discussion created by mwiygul on Feb 21, 2011
Latest reply on Feb 22, 2011 by kimo
Hi, I'm learning to script and have been experimenting with 'cursors'.  I keep getting an error at the command prompt:

RuntimeError: ERROR 999999: Error executing function.  The coordinates or measures are out of bounds." 

By accident I found a workaround but I don't understand why it works and think I shouldn't need it.  I create two varibles to store the polygon.Extent and polygon.Area fields from a feature class that I wish to copy over to another feature class.  I run a gp.Search.Cursor first to find the polygons containing the ZIPCODE to copy. The ZIPCODE argument is retrieved using sys.argv[1] from the command prompt.  I copy the polygon.Shape which I understand encapsulates the area and extent fields within the geoprocessor.  Ayhow, I get the above error message when I attempt to do that.  I then figured I needed to copy the Area and Extent fields and Insert those attributes as well.  After I created the varibles to store the Area and Extent I forgot to Insert them, but it worked!  I tried 'commenting' those varibles back out and get the error.  Then I 'uncomment' the varibles back in and behold, it works! 

If I used some unconventional terms or names its because I'm new.  Sorry, my indentation gets removed when I post.  Thanks for any feedback!

Below is my entire program:

import arcgisscripting, sys
gp = arcgisscripting.create(9.3)
getzip = sys.argv[1]

gp.Workspace = "C:\\Student\\PYTH\\Database\\MySD.mdb"
cur = gp.SearchCursor ("Zipcodes", "[ZIP] = %d" % int(getzip))

#search for polygons based on a zipcode entered as an argument

listID=[]  # store a list of objectid(s) for zipcodes that have numerous polygons
rowa = cur.Next()
counter = 0
while rowa:
    counter +=1
print '%d polygon(s) counted so found meeting criteria' % counter
print 'The  OBJECTID(s) are... ', listID

#search for and save the geometry of each feature with an objectid saved in listID above

for x in listID:
    cur = gp.SearchCursor("Zipcodes", "[OBJECTID] = %d" %x)
    geom=rowb.Shape   # i believe this line should store the entire geometry
    geoA=geom.Area   # error -999999 if I comment this line out
    geoX=geom.Extent   # error - 999999 if I comment this line out

    cur=gp.InsertCursor("polyBlank")   #  insert the geometry and zipcode into a new feature class
    print "added polygon ", x
del cur