1

I created a python add-in which makes analyses like spatial join, update cursor and make feature layer. But when editing is open for a layer. I get this error.

Line 289, in onClick for rec in recs:

RuntimeError: The operation is not supported within an edit session.

targfields3 = ['SHAPE', 'yapi_id', 'mahalle_id', 'YOL_ID', 'Yol_id_butun', 'YOL_ADI']
        with arcpy.da.UpdateCursor('KAPI selection', targfields3) as recs:
            for rec in recs:
                keyval = rec[0]
                if joindict3.has_key(keyval):
                    rec[1] = joindict3[keyval][0]
                    rec[2] = joindict3[keyval][1]
                    rec[3] = joindict3[keyval][2]
                    rec[4] = joindict3[keyval][3]
                    rec[5] = joindict3[keyval][4]
                else:
                    rec[1] = 0
                    rec[2] = 0
                    rec[3] = 0
                    rec[4] = 0
                    rec[5] = 0
                recs.updateRow(rec)
        del rec, recs

This is the operation mentioned in error.

While making this analyses manually, when edit is open on arcmap, I get no error.

I have to work with this python add-in while edit is on. So, solving this error is crucial for me.

  • 1
    Have a look at the Editor class. – Hornbydd Aug 29 '17 at 13:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.