My arcpy script builds a Python dictionary, dictCLPnts, that holds the geometry objects of a polyline feature class. The following code snippet shows the attempt to access the geometry object with the key "rwy":
feat = dictCLPnts[rwy] arcpy.AddMessage('feat is type %s' % (type(feat))) arcpy.AddMessage('partcount = %s' % (str(feat.partCount))) arcpy.AddMessage('pointcount = %s' % (str(feat.pointCount))) part0 = feat.getPart(0) arcpy.AddMessage('part0 is type %s' % (type(part0))) part0.reset() pnt1 = part0.next() if not pnt1: #in case there is a Null pnt at the beginning of the part pnt1 = part0.next() arcpy.AddMessage('pnt1 is type %s' % (type(pnt1))) X1 = pnt1.X Y1 = pnt1.Y
Here is the output:
feat is type <class 'arcpy.arcobjects.geometries.Polyline'> partcount = 1 pointcount = 1002 part0 is type <class 'arcpy.arcobjects.arcobjects.Array'> pnt1 is type <type 'NoneType'> <type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'X'
Looks to me like the points are there (and there isn't any reason for them not to be). I checked the original data, and the points are all there, z-values and all. It draws fine, and Check Geometry reports nothing amiss. I am just baffled by this. Yes, I could refactor and use a cursor (yet again), but that would be hideous at this point in the code. Dictionaries are also a lot faster. If anyone has any insight on this one, please let me know. Thank you, all.