I have an aprx with one map and one layer.
I want to change the extent of the aprx with Python so when the user open the aprx the extent will be full extent (it was save with wrong extent.
I tried the very simple code below, it does not gives an error and the aprx is saved but the extent is unchanged.
When I uncomment the zoomToAllLayers I get an error.
There is some solutions with layout (I do not have it in this aprx).
If I work with the CURRENT aprx then the activeView give me mapView that is working but I do want it to run without open the aprx.
import arcpy aprx = arcpy.mp.ArcGISProject(r"xx.aprx") map1 = aprx.listMaps() mapView = map1.defaultView lyr = map1.listLayers() desc = arcpy.Describe(lyr) print ( str(desc.extent)) mapView.camera.setExtent(desc.extent) #mapView.zoomToAllLayers() aprx.save()
No. I could not find any way to change any other aprx but the CURRENT one.
I found a few other methods in arcpy.mp that works only on the current aprx so I think it is a limitation.