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

382
1
08-02-2019 08:55 AM
орел
Occasional Contributor II

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
1 Reply
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)

0 Kudos