Using "Same as Display" Extent in ArcGIS Pro script?

986
2
08-02-2019 08:55 AM
EricEagle
Occasional Contributor III

The Extent geoprocessing environment setting documentation here:

https://pro.arcgis.com/en/pro-app/tool-reference/environment-settings/output-extent.htm

lists "Same as Display" under the dialog syntax, but not under the scripting syntax.  I am building a script tool that requires "Same as Display" to be set as a default.

Could someone share a snippet of code that demonstrates how I would set arcpy.env.extent to get the same effect as setting "Same as Display" in the dialog window?

0 Kudos
2 Replies
WarrenDavison
Occasional Contributor

Hi Eric,

You should be able to use the following snippet provided the user is running the tool from within Pro and has the map view open.

Warren

aprx = arcpy.mp.ArcGISProject("CURRENT")
mv = aprx.activeView
ext = mv.camera.getExtent()
arcpy.env.extent = "{}, {}, {}, {}".format(ext.XMin, ext.YMin, ext.XMax, ext.YMax)

KirstenHazler
New Contributor III

Thanks, you rock! Cut down a process using feature services as inputs from 13 minutes to 32 seconds.

0 Kudos