RefreshLayer

サマリー

Refreshes the map views containing the specified layers.

説明

Use the RefreshLayer function to refresh the map view after edits have taken place. This can be useful to run when updates to a table, such as with a cursor, do not trigger a refresh of the map view. This will refresh all visible layers in the map view containing the specified layer.

構文

RefreshLayer (layer_name)
パラメーター説明データ タイプ
layer_name
[layer_name,...]

The layer in the table of contents that will be refreshed.

String

コードのサンプル

RefreshLayer example 1

Refresh a layer in the map view after updates to the layer.

import arcpy
lyr_name = "Cities"

with arcpy.da.UpdateCursor(lyr_name, "Class") as ucur:
    for row in ucur:
        row[0] += 1
        ucur.updateRow(row)

arcpy.RefreshLayer(lyr_name)
RefreshLayer example 2

Refresh multiple layers in the map view after updates to the layers.

import arcpy

lyrs = ["fc1", "fc2"]

for lyr_name in lyrs:
    with arcpy.da.UpdateCursor(lyr_name, "Class") as ucur:
        for row in ucur:
            row[0] += 1
            ucur.updateRow(row)

arcpy.RefreshLayer(lyrs)