RefreshActiveView

摘要

Refreshes the active view of the current map document.

讨论

RefreshActiveView is only needed if you want to see the active view of the current map document updated. arcpy.mapping export, save, and printing functions will generate the expected updated results without use of RefreshActiveView.

语法

RefreshActiveView ()

代码示例

RefreshActiveView example

Refresh the current map to reflect zoomToSelectedFeatures.

import arcpy

mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "Cities", df)[0]

# Use the SelectLayerByAttribute tool to select New York and 
#  zoom to the selection
arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", 
                                        "CITY_NAME = 'New York'")
df.zoomToSelectedFeatures()

# Export the map to a .jpg
arcpy.mapping.ExportToJPEG(mxd, "C:/data/NewYork.jpg")

# Clear the selection and refresh the active view
arcpy.SelectLayerByAttribute_management(lyr, "CLEAR_SELECTION")
arcpy.RefreshActiveView()

del mxd

相关主题


7/10/2012