Need to wait for map to draw before changing extent via ArcPy

193
1
10-09-2020 09:35 AM
District_of_Lake_CountryGIS_Ad
New Contributor III

I have a simple Python script that iterates between map extents:

aprx = arcpy.mp.ArcGISProject("CURRENT")
lyt = aprx.listLayouts("Layout")[0]
mf = lyt.listElements("MAPFRAME_ELEMENT", "Map*")[0]

mf.camera.setExtent(arcpy.Extent(330611.83,5553892.48,330863.45,5554011.54))
mf.camera.setExtent(arcpy.Extent(330048.80,5553500.43,332061.75,5554452.93))
mf.camera.setExtent(arcpy.Extent(323271.40,5544979.88,331323.22,5548789.89))
mf.camera.setExtent(arcpy.Extent(326568.38,5548818.46,327071.62,5549056.59))

It appears the map extent changes but does not wait for the map to draw completely before going to the next extent. Any idea how to force the setExtent to wait for the map to draw?

Thanks!

M

Tags (1)
0 Kudos
1 Reply
DonaldShaw2
Esri Contributor

You could import the time module and introduce delays between map extents with time.sleep()