Using ArcMap 10.1, since there is not a way to control portrait or landscape of the layout view through python, is there a way to switch layout templates without opening a new mxd through python?
Since there is a change layout template button it would be nice to have a python function to do the same.
1 Answer 1
You could request this as an ArcGIS Idea but so far, at least for me, requirements like this have been easy to meet by just opening a new MapDocument object so I suspect it would not attract a lot of votes.
For example, when Selecting predefined ArcMap template using ArcPy? means a "predefined template" to be an MXD located in a Map template folder inside an ArcGIS installation directory, it should just need:
mxd = arcpy.mapping.MapDocument(r"Current")
(although there is no need for the r
before "Current" above)
to be replaced with:
mxd = arcpy.mapping.MapDocument(r"<path>\<template>.mxd")
-
I took "predefined template" to mean a layout template you'd typically use the "Change Layout" button on that Layout toolbar in ArcMap. Changing the MapDocument here wouldn't give the same result.2016年01月24日 22:34:03 +00:00Commented Jan 24, 2016 at 22:34
-
@Midavalo I've not tested recently but I think it would at any version from 10.0 onwards i.e. since *.mxt files ceased to be used to define map templates.2016年01月24日 22:37:10 +00:00Commented Jan 24, 2016 at 22:37
-
Predefined templates now use MXD instead of MXT, however the button still exists and functions the same way "Change Layout - Change the Layout by selecting a predefined template" is the tooltip text. Using arcpy.mapping.MapDocument would just make arcpy run on a completely different MXD rather than use one MXD as a template for the CURRENT.2016年01月24日 22:41:28 +00:00Commented Jan 24, 2016 at 22:41
-
@Midavalo There's no ArcPy method to do precisely that, and ArcPy is primarily designed for map automation with less emphasis on using it interactively within ArcMap. I think that is a pity sometimes, but I think it also means that the way I have suggested may be the asker's best option.2016年01月24日 22:48:05 +00:00Commented Jan 24, 2016 at 22:48