I was creating polygons via a python script when I noticed that rows in the table were being inserted but some of the actual polygon shapes were missing. I had just rewritten this 9.3.1 python script to work with arcpy and version 10+. I ran the 9.3.1 script and all polygon shapes were complete.
I opened ArcMap 10.2.1 and manually entered the new code into the Python window:
>>> import arcpy
>>> array = arcpy.Array()
>>> array.add(arcpy.Point(-92.09936200, 46.73024000))
>>> array.add(arcpy.Point(-92.09936200, 46.73137900))
>>> array.add(arcpy.Point(-92.09782100, 46.73137900))
>>> array.add(arcpy.Point(-92.09782100, 46.73024000))
>>> array.add(arcpy.Point(-92.09936200, 46.73024000))
>>> cur = arcpy.da.InsertCursor("onecall_poly", ["SHAPE@"])
>>> cur.insertRow([arcpy.Polygon(array)])
0L
>>> array.removeAll()
>>> del array, cur
This created a row in the feature class table but did not create a polygon.
I then typed the following code into the Python window:
>>> import arcgisscripting
>>> gp = arcgisscripting.create(9.3)
>>> array = gp.createobject("Array")
>>> pnt = gp.createobject("Point")
>>> pnt.x = -92.09936200
>>> pnt.y = 46.73024000
>>> array.add(pnt)
>>> pnt.x = -92.09936200
>>> pnt.y = 46.73137900
>>> array.add(pnt)
>>> pnt.x = -92.09782100
>>> pnt.y = 46.73137900
>>> array.add(pnt)
>>> pnt.x = -92.09782100
>>> pnt.y = 46.73024000
>>> array.add(pnt)
>>> pnt.x = -92.09936200
>>> pnt.y = 46.73024000
>>> array.add(pnt)
>>> cur = gp.insertcursor("onecall_poly")
>>> feat = cur.newrow()
>>> feat.shape = array
>>> cur.insertrow(feat)
>>> array.removeall()
>>> del cur, array
This created the table record and the polygon feature.
Am I doing something wrong? Why doesn't the new code work? In the help it says that "All geometries are validated before they are written to a feature class." What does 0L mean after the insertRow command in my first example?