サマリー
Determines whether the given dataset or workspace is in an edit session.
説明
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.
構文
IsBeingEdited (dataset)
パラメーター | 説明 | データ タイプ |
dataset | The input dataset or workspace to be checked for an ongoing edit session. | String |
データ タイプ | 説明 |
Boolean | True if the input dataset or workspace is in an edit session. |
コードのサンプル
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)