Summary
Refreshes the map views containing the specified layers.
Discussion
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.
Syntax
RefreshLayer (layer_name)
Parameter | Explanation | Data Type |
layer_name [layer_name,...] | The layer in the table of contents that will be refreshed. | String |
Code sample
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)
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)