Eddie63

arcpy.da.UpdateCursor SHAPE@ error when updating M-values

Discussion created by Eddie63 on May 28, 2014
Latest reply on Apr 13, 2016 by SWalbridge-esristaff

When updating M-values in a feature class using the data access module, I encounter the error below when I run the following code on a selected segment in ArcMap using a Python Add-In call to a Python tool. However, the M-values still update. I am wondering if this is a bug. I also tried this using "SHAPE@JSON" and got the same error, but the M-values still updated. Anybody else have this issue, or have some insight on why this error is being thrown?

 

I am doing this inside an ArcMap edit session (ESRI Editor). After I run the da.updateCursor, I do some other non 'da' updates, so the commits get pushed through SDE to the underlying SQLServer database. I am on 10.2.1

 

import json, math 
lin_ref = {'MILEPOST_FR': 1, 'MILEPOST_TO': 10} 
with arcpy.da.UpdateCursor(segmentfc,["SHAPE@"]) as cursor:
    for row in cursor:
        json_obj = json.loads(row[0].JSON)
        mp_to = len(json_obj['paths'][0]) - 1
        fulldist = row[0].getLength('PLANAR', 'FEET')
        conversionfactor = (math.fabs(lin_ref['MILEPOST_TO'] 
                                      - lin_ref['MILEPOST_FR']) / fulldist)
        for i,v in enumerate(json_obj['paths'][0]):
            if i == 0:
                json_obj['paths'][0][i][2] = float(lin_ref['MILEPOST_FR'])
            else:                 
                # distance in map units between last vertex and current vertex
                x1vert = json_obj['paths'][0][i][0] - json_obj['paths'][0][i-1][0]
                y1vert = json_obj['paths'][0][i][1] - json_obj['paths'][0][i-1][1]
                vertdist = math.sqrt(x1vert**2 + y1vert**2)
                vert_lrdist = vertdist * conversionfactor
                json_obj['paths'][0][i][2] =  json_obj['paths'][0][i-1][2] + float(vert_lrdist)
         for feature in json_obj['paths']:
             pline = arcpy.Polyline(arcpy.Array(
                 [arcpy.Point(X=coords[0], Y=coords[1], M=coords[2])
                 for coords in feature]), row[0].spatialReference, False, True)
        row[0] = pline
        cursor.updateRow(row)  

Traceback (most recent call last):   
File "<string>", line 1896, in execute SystemError: error return without exception set

 


The line where the error occurs is

cursor.updateRow(row)

Outcomes