Using ArcGIS pro 3.3
In a stand-alone python script, copying a aprx and changing the source and some other properties... ArcGIS pro is not running. There are two problems. One if the Mapview extent and rotation (heading) is not updated when I open the project. If I close the map view and re-open the map, the extent is set but not the heading. I would like if when the project is open, the mapview would be centered on the extent and the rotation would be set. The activeMap and activeView are None at run time.
aprx = arcpy.mp.ArcGISProject(self.templateAPRX) #file name of the default
aprx.updateConnectionProperties(current_connection_info= self.templateGDB, new_connection_info= self.projectGDB)
I I do this inside ArcGIS pro python window, I get the same problem with the heading if it is applied on the map (closed map) but the set extent works. Heading and extent work on the activeView but these are None for me.
Can I set the map extent and rotation for a project without having it open?
logging.info("set rotation to {angle}".format(angle=str(self.analysisRotation)))
listEditMap = aprx.listMaps(self.editorMap)
if len(listEditMap) != 1:
raise Exception("There must be exactly one map named {mapname}, {cnt} were found".format(self.editorMap, str(len(listEditMap))))
editMap = listEditMap[0]
editMap.defaultCamera.heading = self.analysisRotation *-1
if self.analysisPolygon:
editMap.defaultCamera.setExtent(self.analysisPolygon.extent)
editMap.openView() #does nothing if the aprx is not current?
aprx.saveACopy(self.projectAPRX)