Skip to main content
formatting
Source Link
matt wilkie
  • 28.3k
  • 35
  • 149
  • 283

As you've already surmised,

df.zoomToSelectedFeatures()

will change the extents of the data frame to all selected features in the map frame. If you're interested in just zooming to a selection set for a specific layer then use "lyr.getSelectedExtent()"lyr.getSelectedExtent(). I also adjust the map scale factor so my code either looks like this:

df.extent = lyr.getSelectedExtent()
df.scale *= 1.5
arcpy.RefreshActiveView()

or this:

df.extent = lyr.getSelectedExtent()
df.scale = 12000 # 1:1,000
arcpy.RefreshActiveView()

As you've already surmised,

df.zoomToSelectedFeatures()

will change the extents of the data frame to all selected features in the map frame. If you're interested in just zooming to a selection set for a specific layer then use "lyr.getSelectedExtent()". I also adjust the map scale factor so my code either looks like this:

df.extent = lyr.getSelectedExtent()
df.scale *= 1.5
arcpy.RefreshActiveView()

or this:

df.extent = lyr.getSelectedExtent()
df.scale = 12000 # 1:1,000
arcpy.RefreshActiveView()

As you've already surmised,

df.zoomToSelectedFeatures()

will change the extents of the data frame to all selected features in the map frame. If you're interested in just zooming to a selection set for a specific layer then use lyr.getSelectedExtent(). I also adjust the map scale factor so my code either looks like this:

df.extent = lyr.getSelectedExtent()
df.scale *= 1.5
arcpy.RefreshActiveView()

or this:

df.extent = lyr.getSelectedExtent()
df.scale = 12000 # 1:1,000
arcpy.RefreshActiveView()
Source Link

As you've already surmised,

df.zoomToSelectedFeatures()

will change the extents of the data frame to all selected features in the map frame. If you're interested in just zooming to a selection set for a specific layer then use "lyr.getSelectedExtent()". I also adjust the map scale factor so my code either looks like this:

df.extent = lyr.getSelectedExtent()
df.scale *= 1.5
arcpy.RefreshActiveView()

or this:

df.extent = lyr.getSelectedExtent()
df.scale = 12000 # 1:1,000
arcpy.RefreshActiveView()