Select to view content in your preferred language

How do I call out a specific layout window to export?

656
2
Jump to solution
03-22-2023 01:08 PM
avonmoos
Regular Contributor

My current script is exporting all of my layout windows. Does anyone have an example of how I can export a specific layout window?

 

import arcpy


docPath = r"*PATH*"
docName = r"Test.aprx"
p = arcpy.mp.ArcGISProject(docPath+"\\"+docName)
# ge a list of all layouts in your map dox
lLayout = p.listLayouts()
for l in lLayout:
    print(l.name)
    #You could add an if statement to print ONLY a specific layout
    l.exportToJPEG(docPath+"\\"+l.name)

print("Process Completed")

 

0 Kudos
1 Solution

Accepted Solutions
DavidPike
MVP Frequent Contributor

Is the script from a previous answer?  Unless I'm misinterpreting, you just need the syntax for an if statement?

import arcpy


docPath = r"*PATH*"
docName = r"Test.aprx"
layoutName = 'name of your layout'
p = arcpy.mp.ArcGISProject(docPath+"\\"+docName)
# ge a list of all layouts in your map dox
lLayout = p.listLayouts()
for l in lLayout:
    print(l.name)
    #if statement to print ONLY a specific layout
    if l.name == layoutName:
        l.exportToJPEG(docPath+"\\"+l.name)

print("Process Completed")

View solution in original post

0 Kudos
2 Replies
DavidPike
MVP Frequent Contributor

Is the script from a previous answer?  Unless I'm misinterpreting, you just need the syntax for an if statement?

import arcpy


docPath = r"*PATH*"
docName = r"Test.aprx"
layoutName = 'name of your layout'
p = arcpy.mp.ArcGISProject(docPath+"\\"+docName)
# ge a list of all layouts in your map dox
lLayout = p.listLayouts()
for l in lLayout:
    print(l.name)
    #if statement to print ONLY a specific layout
    if l.name == layoutName:
        l.exportToJPEG(docPath+"\\"+l.name)

print("Process Completed")
0 Kudos
avonmoos
Regular Contributor

I found the example through Google and noticed the if statement comment after I had posted this. Thanks for the quick response.