Example: Zoom to Selected Features From
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
df.zoomToSelectedFeatures()
del mxd
This example assumes you have layers already selected in the current map document.
Example: Changing Data Frame's Size and Position
import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\temp\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd)[0]
df.elementPositionX, df.elementPositionY = 1, 1
df.elementHeight, df.elementWidth = 5, 6.5
mxd.save()
del mxd
Example: Spatial Query by Visible Extent
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
layers = arcpy.mapping.ListLayers(mxd, "", df)
# Extent Polygon
extentPolygon = arcpy.Polygon(arcpy.Array([df.extent.lowerLeft,df.extent.lowerRight, df.extent.upperRight, df.extent.upperLeft]),
df.spatialReference)
# Select all features in current extent
for lyr in layers:
arcpy.SelectLayerByLocation_management(lyr, "INTERSECT", extentPolygon, "", "NEW_SELECTION")
del mxd
Enjoy