9

Is there a way to change from layout view to data view using Python and ArcMap 10?

I would prefer to do it using ArcPy.

  • Just curious, what's the use case for wanting to do this? – Derek Swingley Sep 28 '10 at 22:43
  • I originally wanted to do this because in ArcMap 10 the buttons to switch to layout or data view disappear sometimes. I thought I could simply change it using Python, but I still haven't been able to. It's not a solution to the problem, but I was more interested in learning how to do this in python anyway. – Tanner Sep 30 '10 at 3:36
9
mxd = arcpy.mapping.MapDocument('CURRENT')
mxd.activeView = "my_data_frame_name"
arcpy.RefreshActiveView()
8

To go the other way is as easy as:

arcpy.mapping.MapDocument("current").activeView = "PAGE_LAYOUT"
  • Thank you. I see the mention of "PAGE_LAYOUT" now in the online documentation. I appreciate you pointing this out. It's the last thing I needed for porting a 60-page mapping tool written in VBA and ArcObjects to a 10-page tool written with Python and arcpy. Plus, I can also take advantage of data driven pages. Thanks again! – user1853 Feb 3 '11 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.