AnsweredAssumed Answered

Zoom map to the extent of a layer in Arcpy.mp (ArcGIS Pro Project)

Question asked by james_taylor-esristaff Employee on May 2, 2017
Latest reply on Jul 3, 2018 by simo

I'm writing code to create new ArcGIS Pro Projects using the Pro arcpy  (package arcpy.mp)

 

Doing something like this:

 

import arcpy.mp
aprx = arcpy.mp.ArcGISProject(r"C:\temp\Empty.aprx")
map = aprx.listMaps()[0]
map.map.addDataFromPath(r"C:\Users\xxxxxx\Documents\Test1\Orthomosaic.tif")
aprx.saveACopy(r"C:\temp\jNew.aprx")

 

But I can't figure out to zoom the map to the extent of Orthomosaic.tif (or any other extent for that matter).

 

From the docs at   Alphabetical list of arcpy.mp classes—ArcPy | ArcGIS Desktop 

I can see that a MapFrame has a zoomToAllLayers method, but a MapFrame is only available on a Layout element.

 

Anyone know how to do this?

 

Thanks.

Outcomes