Select to view content in your preferred language

Are arcpy.da.Editor and ArcGIS Pro edit session completely separate?

840
10
Jump to solution
11-04-2025 10:17 AM
Jeff-Reinhart
Frequent Contributor

I need to be able to use arcpy.da.Editor within the context of an existing ArcGIS Pro edit session. Is this possible or are the two completely separate?

Use Case:

Application where single workspace edit sessions are required. Datasets are traditional versioned. User has an edit session running to modify shapes and attributes. User then needs to run a Python script for an automated part of their workflow. That Python script updates a value in a record in one of the versioned datasets. User then decides to discard edits. That discard should also drop the change that the Python script made.

What I Have Tried:

Start editing in ArcGIS Pro via Edit tab | Edit button

Run this code:

myLayer = sys.argv[1] # Parameter with Data Type: Feature Layer
edit = arcpy.da.Editor(r'c:\path\mysde.sde')
edit.startEditing(False, True)
edit.startOperation()
with arcpy.da.UpdateCursor(myLayer, ['thefield'], "objectid = 1") as ucur:
    for urow in ucur:
        urow[0] = 'new value'
        ucur.updateRow(urow)
edit.stopOperation()
edit.stopEditing(True)

This results in the edits being made, but the Edit tab | Save button does not enable, which tells me the edits were not made within the existing ArcGIS Pro edit session.

I have also tried using arcpy.management.CalculateField, but if there is an ArcGIS Pro edit session when that is run, the Pro edit session gets stopped.

Is there any other way to edit attributes within the ArcGIS Pro edit session from Python?

10 Replies
Jeff-Reinhart
Frequent Contributor

An amendment to this that is worth noting...

While the arcpy.da.Editor is separate from an ArcGIS Pro editing session, parts of arcpy are very much NOT separate from the Pro editing session. As I recently learned in this discussion:

https://community.esri.com/t5/python-questions/arcpy-analysis-clip-stops-edit-session/m-p/1673659

A large swath of arcpy modules will actually STOP a Pro edit session automatically.

0 Kudos