Running ArcGIS Pro 2.9.1 on Windows 10 Enterprise v. 1607 (OS Build 14393.4886), also Windows 10 v. 20H2 (OS Build 19042.1526).
Problem: activeView always returns None. Steps to reproduce:
1) Create new Map project.
2) Open Notebook or Python Window
3) Include this code taken from https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/mapview-class.htm :
import arcpy, os
aprx = arcpy.mp.ArcGISProject('current')
mv = aprx.activeView
# Change the extent of the map view
ext = mv.camera.getExtent()
4) Result:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
In [16]:
Line 7: ext = mv.camera.getExtent()
AttributeError: 'NoneType' object has no attribute 'camera'
---------------------------------------------------------------------------
aprx.activeMap works, as does aprx.activeMap.defaultView, but I'm pretty limited if I can't manipulate the camera!
The docs say "The activeView property is intended for scripts that are to be executed in the ArcGIS Pro application, such as scripts run in the Python pane or those associated with a script tool", which is what I'm trying. What am I missing?
Thanks,
-- Andy