Add enable/disable edit/selection method to Layer Class

506
2
08-01-2023 10:57 AM
Status: Already Offered
Labels (1)
macbeer
New Contributor II

In Pro, I can enable/disable editing/selection of specific layers  via the List by Editing tab and the List by Selection tab.

I would like to be able to be able to do the same using arcpy.

Example use case:

I have a map with specific layers that I want to protect the source data from being inadvertently modified during an edit session.

I would run a script tool to disable editing and or selection for specific layers in my map.

2 Comments
JeffBarrette
Status changed to: Already Offered

This is something that can be done using Python CIM Access

p = arcpy.mp.ArcGISProject('current')
m = p.listMaps()[0]
l = m.listLayers('Cities')[0]

l_cim = l.getDefinition('V3')         #Get the layer's CIM definition
l_cim.featureTable.editable = False   #Modify the editable state
l.setDefinition(l_cim)                #Push the CIM changes back to the layer
macbeer

Awesome, thanks for the example.