I've written an arcpy script that pulls coordinate data from a saved email/text file. I've also added the polygon created into a feature class, and used a definition query on the layer so that the new feature is the only one visible in the map.
What I'm trying to do is pan the layout's map frame to the new extent of the layer. The following script works (i.e. retains the current scale of the map frame, and pans to the layer), but it throws the included error. I'm running my script in ArcGIS Pro 2.9.
I've already read the MapFrame and Camera classes
https://pro.arcgis.com/en/pro-app/2.9/arcpy/mapping/mapframe-class.htm
https://pro.arcgis.com/en/pro-app/2.9/arcpy/mapping/camera-class.htm
I can't find ANY examples of how to use the MapFrame panToExtent method. Please help.
aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps("811Tickets")[0]
lyr = m.listLayers("AZ811 BlueStake")[0]
lyt = aprx.listLayouts()[0]
mf = lyt.listElements("mapframe_element", "MainMapFrame")[0]
mf.camera.setExtent(mf.panToExtent(mf.getLayerExtent(lyr, False, True)))
Traceback (most recent call last):
File "<string>", line 6, in <module>
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py", line 389, in setExtent
return convertArcObjectToPythonObject(self._arc_object.setExtent(*gp_fixargs((extent,), True)))
TypeError: Camera.setExtent() missing required argument 'extent' (pos 1)