Python to change the paper size of a layout

656
2
09-26-2022 02:35 AM
Status: Already Offered
Labels (1)
CarolineLindhe
Occasional Contributor

I'm new to Python but would like to create a script that makes it easy for me to change the paper size of a layout. As of today I have 10 different layouts to choose between (5 different sizes+2 different orientations). This means that I need to update 10 different layout templates every time they need to change. 

I rather see that I only need to update on template but that I can change the size and orientation with Python. It is important though that the script includes size differences for different elements around the map as well as for the gridlabels. For example the script should be able to change the title size from 10, 12, 14, 16 depending on the size choosen.

Anyone that has already invented this wheel?

Tags (2)
2 Comments
JeffBarrette
Status changed to: Already Offered

Arcpy.mp provides the ability to change pages sizes as well as element sizes.  Trying to automate the resizing of elements to match 10 possible configurations, including orientation, would NOT be a simple script.  The application recently provided new resizing options (see graphic below) that will attempt to resize elements based on a newly chosen page size but the result almost always requires some fine tuning to get everything aligned just the way you would want it.  It would only work perfectly if the aspect ratios for all elements are the same.

I think the best way to tackle this solution using Python would be to follow the techniques used in this downloadable sample: https://www.arcgis.com/home/item.html?id=82b99b5593e54e57b740e3898fb14c5f

It persists all the layout elements, sizes, and positions in a database table.  The script reads the table and recreates the layout based on the information in the table.  The script/table could easily be modified to include layout size.  There is a detailed README in the sample that will provide more detail.

Capture.PNG

CarolineLindhe

Thanks Jeff, certainly something to look deeper into. At first glance it sound a little bit like the MRG production based on MGCP that I worked on a few years ago.