Select to view content in your preferred language

Update cursor on layer with attachments - Arcpy Runtime Error

1862
2
Jump to solution
03-12-2019 07:41 AM
TylerSchlachter
Occasional Contributor

I am trying to use an update cursor to update the geometry of several thousand features that were collected in ArcCollector (basically snapping lines to points based on a field in the line layers attributes). The features that were collected in ArcCollector have attachments and attachment relation tables, and it appears that this is causing some trouble when I run my arcpy script.

 

I get the following error when I try to open an UpdateCursor in Arcpy on the layer:

 

Traceback (most recent call last):

  File "<string>", line 6, in <module>

RuntimeError: Objects in this class cannot be updated outside an edit session [Pipes]

I'm working in ArcGIS Pro.

If I remove the attachments and attachment relations table from the geodatabase, I can run the script no problem. An alternative would be to run the script on just the geometry, then replace the geometry layer in the geodatabase that contains the attachment table and attachments. But this doesn't actually seem to work when I try to go about it in the catalog view.

 

I'm guessing this has something to do with the geodatabase version, or something along those lines. Any insight would be greatly appreciated. Thank you,

0 Kudos
1 Solution

Accepted Solutions
JakeSimms1
Esri Contributor

Tyler - 

if in ArcPro using the arcgis module  look into the Version operation in he submodules arcgis.features.managers it has the option to start a edit session. There are also other various editing module here as well.

You can modify your current script to open an edit session (arcpy). Something like:

arcpy.env.workspace = workspace

#start an edit session
edit = arcpy.da.Editor(workspace)

# Edit session is started without an undo/redo stack for versioned data
# (for second argument, use False for unversioned data): startEditing ({with_undo}, {multiuser_mode})
edit.startEditing(True, True)
print ("start an edit session")

# Start an edit operation
edit.startOperation()

 

View solution in original post

2 Replies
JakeSimms1
Esri Contributor

Tyler - 

if in ArcPro using the arcgis module  look into the Version operation in he submodules arcgis.features.managers it has the option to start a edit session. There are also other various editing module here as well.

You can modify your current script to open an edit session (arcpy). Something like:

arcpy.env.workspace = workspace

#start an edit session
edit = arcpy.da.Editor(workspace)

# Edit session is started without an undo/redo stack for versioned data
# (for second argument, use False for unversioned data): startEditing ({with_undo}, {multiuser_mode})
edit.startEditing(True, True)
print ("start an edit session")

# Start an edit operation
edit.startOperation()

 

TylerSchlachter
Occasional Contributor

This worked. I wrapped the update cursor in an edit session. Thank you

0 Kudos