How to get user current extent in arcpro

776
2
10-31-2017 12:00 PM
ChadCarlson1
New Contributor

I am trying to figure out how to write python code to get the user current extent from the map view. so far I have this

aprx = arcpy.mp.ArcGISProject('Current')

mp = aprx.listMaps()[0]

view = mp.defaultCamera

print(view.getExtent())

however, I have to manually hit save for the getExtent to work. is there a way to get the current extent from the Map view?

0 Kudos
2 Replies
DanPatterson_Retired
MVP Emeritus

Save the script? or the project?

0 Kudos
ianmcintosh
New Contributor II

I have found that I could manually go to Project > Save and run the code which will give me the updated extent. However, I am trying to avoid making users do this. I know desktop I can get the user current extent from dataframes, but i can't figure it out with pro. Also, the save() method doesn't work well in the python console. it'll save the project but will not update the extent.

0 Kudos