PauseDrawing

Summary

Pauses the drawing of the map view while working with it within a context manager.

Discussion

The PauseDrawing class is a context manager that can be used to pause the drawing of the map view while updates are being applied to a layer. Even if the RefreshLayer function is called within the PauseDrawing context manager, the map view will not refresh until the with block is exited.

Syntax

PauseDrawing ()

Code sample

PauseDrawing example

Using the PauseDrawing class as a context manager while updates are applied with update cursors.

import arcpy
from random import randint
featureclass_1 = r"c:\data\myGDB.gdb\fc1"
featureclass_2 = r"c:\dat\myGDB.gdb\fc2"

with arcpy.PauseDrawing():
    with arcpy.da.UpdateCursor(featureclass_1, "class") as cursor:
        for row in cursor:
            classification = randint(1, 5)
            row[0] = classification
            cursor.updateRow(row)
    with arcpy.da.UpdateCursor(featureclass_2, "class") as cursor:
        for row in cursor:
            classification = randint(1, 5)
            row[0] = classification
            cursor.updateRow(row)
    arcpy.RefreshLayer((featureclass_1, featureclass_2))

# The map view will refresh now that the PauseDrawing context manager has closed.