Zusammenfassung
Determines whether the given dataset or workspace is in an edit session.
Diskussion
The IsBeingEdited method can be used to check if a data source is currently in an edit session. This is similar to the isEditing property on the Editor class but does not require you to create the Editor object. This can be useful to use on data sources in which multiple users or automated scripts are trying to perform edits at the same time.
Syntax
IsBeingEdited (dataset)
Parameter | Erläuterung | Datentyp |
dataset | The input dataset or workspace to be checked for an ongoing edit session. | String |
Datentyp | Erläuterung |
Boolean | True if the input dataset or workspace is in an edit session. |
Codebeispiel
The following code checks if the workspace is already in an edit session before starting a new one.
import arcpy
arcpy.env.workspace = r"C:\data\myGDB.gdb"
if not arcpy.IsBeingEdited(arcpy.env.workspace):
edit = arcpy.da.Editor(arcpy.env.workspace)
edit.startEditing()
The following code lists the name of any feature layers in a map that have pending edits.
import arcpy
aprx = arcpy.mp.ArcGISProject("CURRENT")
map = aprx.listMaps()[0]
for lyr in map.listLayers():
if lyr.isFeatureLayer and arcpy.IsBeingEdited(lyr):
print(lyr.name)