I'm new to Python (v 2.6.5) and am trying to write an ArcMap (10) script that reads the vertex coordinates of a polygon shapefile which includes a small hole (doughnut polygon). I've been working from the ESRI Help page on reading geometries. The script I've developed outputs coordinate information until it hits coordinate 1025 of 1088 at which point it fails with the error "Array: GetObject not point". I suspect this is the 'null point object' returned as the separator between my outer and inner rings (described in the Help), but I'm stumped on how to account for this in a way that my script doesn't fail (I thought the "if pnt:" line would handle that...). Here's my script - thanks for any guidance!
import arcpy
infc = arcpy.GetParameterAsText(0)
desc = arcpy.Describe(infc)
shapefieldname = desc.ShapeFieldName
rows = arcpy.SearchCursor(infc)
for row in rows:
feat = row.getValue(shapefieldname)
arcpy.AddMessage("Feature %i:" % row.getValue(desc.OIDFieldName))
partnum = 0
for part in feat:
pointnum = 0
arcpy.AddMessage("Part %i:" % partnum)
for pnt in feat.getPart(partnum):
if pnt:
arcpy.AddMessage("Point number " + str(pointnum) + ": " + str(pnt.X)+ ", " + str(pnt.Y))
pointnum += 1
else:
arcpy.AddMessage("Interior Ring:")
partnum += 1