Select to view content in your preferred language

Creating a new Layout with python

5822
6
03-30-2021 03:16 PM
Labels (1)
HaileyG
Emerging Contributor

I am trying to write a python script that will allow me to create multiple templates based on page size/ setup. I am trying to figure out how to insert a new blank layout tab using python script. Does anyone know the syntax for this?

Any other help with python scripts for layout formatting would also be greatly appreciated.

Thanks! 

0 Kudos
6 Replies
TomBole
Esri Regular Contributor
0 Kudos
HaileyG
Emerging Contributor

Thank you! 

0 Kudos
pkaniouras
Occasional Contributor

Hi there!

 

Did you figure out how to create a new layout? All the scripts I read just open an existing one.

0 Kudos
Hailey_G
Emerging Contributor

No I was never able to figure it out. I ended up creating a master aptx, without a script, with all of the layouts I would need. Then when I open it, I choose the layouts I want and delete the others. 

0 Kudos
HaDoMinh
New Contributor

Hi HaileyG, 

I hope that will help you 

#Create the new layout
layout_name = 'layout_test'
layout = project.listLayouts()
print (layout)
#Check if the layout exits already, if not, create it
if not layout:
print ('No Layout')
layout = project.createLayout(210,297, 'MILLIMETER', layout_name)
else:
print ('we have one layout')
layout = layout[0]

print (layout.name)

How to create new Layout using arcpy was list under is acpy.mp class and also mentioned in Layout class. as TomBole mentioned.

0 Kudos
HaDoMinh
New Contributor

project  = arcpy.mp.ArcGISProject(project_path) 

if you wonder what is the project

 

0 Kudos