I'm stumped. The following documentation says activeView will return the active MapView or Layout. I've searched high and low trying to find code to use which will tell me If the "active view" is a map or a layout but am having zero luck.
Any insight appreciated.
Thanks!
MapView—ArcGIS Pro | Documentation
Solved! Go to Solution.
Just check the type of the object or class inheritance:
>>> type(aprx.activeView)
<class 'arcpy._mp.Layout'>
>>> isinstance(aprx.activeView, arcpy._mp.Layout)
True
Just check the type of the object or class inheritance:
>>> type(aprx.activeView)
<class 'arcpy._mp.Layout'>
>>> isinstance(aprx.activeView, arcpy._mp.Layout)
True
Thanks so much Joshua!
If my response answered your question, please mark it Correct to cloud out the question.
Just did, thanks. Had been away from my computer...
Once I've got the activeView how do I grab the name of the MapView or Layout?
view = aprx.activeView
name = view.map.name
ah .map.name
I was trying just .name
Suppose it makes sense when you think about it though.
Are these properties documented anywhere? Then only documentation I could find about activeView is basicallly the page I linked in the original question.
Thanks!
It is all in the documentation. The MapView—ArcGIS Pro | Documentation documentation shows a "map" property that returns a Map—ArcGIS Pro | Documentation object that has a "name" property.
You just need to follow the bread crumbs.
True. So I came up with the following:
When the active view is a map it displays the map name and when the active view is a layout it displays the layout name.
I was thinking that getting the name of the active layout should be mv.layout.name but no it's just mv.name
Logically it doesn't really make sense to me, but it works and I'm happy with that.
Thanks for all your help