in ArcGIS Pro 2.6.2 I have a map named "VTPK Output" and I want to set the map's extent to the extent of a layer called "PACKAGE_AREA" in a python script. There are other maps in my project.
The layer has a definition query that is set to a particular area. I will then change the query and run my script for another area, but it needs to set the map extent property. As you can image, the script is creating a vector tile cache.
I've written some python scripts, but I'm between novice and rookie....
Thanks for your help in advance.
John
I'm a rookie myself with ArcGIS Pro, but I think this is done with a 'camera' object.
I think there's a good example/code sample here - Camera—ArcGIS Pro | Documentation
this is 'camera sample 1':
import arcpy
aprx = arcpy.mp.ArcGISProject(r"C:\Projects\YosemiteNP\Yosemite.aprx")
m = aprx.listMaps("Yose*")[0]
lyr = m.listLayers("Ranger Stations")[0]
lyt = aprx.listLayouts("Main Attr*")[0]
mf = lyt.listElements("mapframe_element", "Yosemite National Park")[0]
mf.camera.setExtent(mf.getLayerExtent(lyr, False, True))
aprx.saveACopy(r"C:\Projects\YosemiteNP\Yosemite_Updated.aprx")
del aprx