RefreshActiveView (arcpy)
摘要
刷新当前地图文档的活动视图和内容列表。
讨论
RefreshActiveView 函数仅在您想要查看当前地图文档更新的活动视图时使用,需要 arcpy.mapping 下的导出、保存和打印函数会生成预期的更新结果,而无需使用 RefreshActiveView。
语法
RefreshActiveView ()
代码实例
RefreshActiveView 示例
刷新当前地图并调用 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
相关主题
5/10/2014