Select to view content in your preferred language

Using Python to Change Layout Templates

2032
9
02-12-2013 03:04 PM
Status: Implemented
Labels (1)
KacieVanasse
New Contributor II
It would be beneficial to be able to use the arcpy.mapping module to change the layout template in the layout view by pointing to the path of the template.

For example, currently on the layout toolbar there is a button called Change Layout. When you click it a window will pop up allowing you to change your layout template to something else (ex. Architectural Page Sizes > ARCH A Portrait.mxd).

It would be nice if users were able to incorporate the selection of this template in python scripting for map making purposes.
9 Comments
BertHavekes
I agree with kvanasse. Changing the layout (while using "CURRENT" as mapdocument) is an important improvement!
CraigAnderson

Have there been any thoughts from ESRI on this?

This would be a valuable addition to arcpy, as I could create some great automation scripts for my users who must often replicate the same map in multiple sizes.

JeffBarrette
Status changed to: Under Consideration

Thank you for your feedback.  There is a long answer to this. 

First, the Layout team is developing commands for 3.1 that allow you to resize a layout AND have an option to scale layout elements proportionally.  The same resize boolean is available to copying a layout. 

Second, arcpy.mp (NOT arcpy.mapping in ArcMap) is also being expanded.  At 3.1 we are adding content management functions to copy project items like maps, layouts, and reports.  This allows you to make a copy and then automate changes to the copy.  arcpy.mp already allow you to change the page size - the problem is that is does NOT automatically resize elements.  That option can't come until after the Layout commands are completed.  At 3.1 arcpy.mp is also adding the ability to CREATE new maps but NOT layouts (yet).  That is because arcpy.mp traditionally doesn't allow you to create new objects so why create a layout when you can't create things like map frames, scalebars, etc.  This is definitely something we want to get to longer term. 

Jeff - Layout and arcpy.mp teams

saraswathiemani2

With reference to layouts (" but NOT layouts (yet)"), do we have in arcpy now to create a new layout? 

Thank you in advance.

JeffBarrette

@saraswathiemani2 we are introducing the following at 3.2.  ArcGISProject functions can create elements on a layout OR a graphics layer in a map.

ArcGISProject.createLayout()

Layout.createMapFrame()

Layout.createMapSurroundElement()

ArcGISProject.createGraphicElement()

ArcGISProject.createGroupElement()

ArcGISProject.createPictureElement()

ArcGISProject.createPreDefinedGraphicElement()

ArcGISProject.createTextElement()

JeffBarrette
Status changed to: In Product Plan

This should be available with Pro 3.3.

Layout.changePageSize(page_width, page_height, {resize_elements=True})

 

Jeff - Layout and arcpy.mp teams

KoryKramer
Status changed to: Implemented

This is implemented in ArcGIS Pro 3.3. See Your Ideas in ArcGIS Pro 3.3 for a full list of all user ideas you can look forward to! And be sure to check out the release blog and what’s new help topic and video to learn more about all the new features and functionality in the release.

CoreyMaize

@KoryKramer @JeffBarrette 
It would be wonderful to have a clone, copy, or duplicate function as part of arcpy.mp in order to automate layout duplication- we often arrange a layout as we would like for a project, and then duplicate it a certain number of times as needed per project, which can sometimes be repetitive. While we could use the standard Map Series Page process, it does not work out of the box for our use case as we require graphic assignment based on individual sheets. Having a clone/copy/duplicate function would be a very easy solution to our current hurdle.

Currently it seems the only way to duplicate a layout is by clicking "Duplicate" on the layout list over and over again, which is not very straightforward for this use case.

JeffBarrette

Hello @CoreyMaize ,

Have you looked at: ArcGISProject.copyItem()

JeffBarrette_0-1717166126378.png

https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/arcgisproject-class.htm

You can easily iterate over however many times you want to duplicate a layout and give each one a unique name.

Jeff - arcpy.mp and Layout teams