5

Is there a way to batch export layouts in an ArcGIS Pro document to a specific format?

For example exporting all layouts to PDF in a file directory.

This was possible with multiple MXDs using python with Desktop, however I haven't found a way to do this with Pro.

0

3 Answers 3

6

This is what I use to do this. the print statement is completely unnecessary though, especially since this is run as a script tool in ArcGIS Pro.

import arcpy

aprx = arcpy.mp.ArcGISProject("CURRENT")
figFolder = arcpy.GetParameterAsText(0)

for lyt in aprx.listLayouts():
    print(" {0} ({1} x {2} {3})".format(lyt.name, lyt.pageHeight, lyt.pageWidth, lyt.pageUnits))
    lyt.exportToPDF(figFolder + "\\" + lyt.name + ".pdf")
4

As commented by @KHibma with respect to the listLayouts method of the APRX object:

Combine the 2 code samples (near the bottom) from here: http://pro.arcgis.com/en/pro-app/arcpy/mapping/layout-class.htm and you'll export all layouts in a project to PDF

-1

I had to take out the figFolder = line from lynryd's code above. I was getting an error telling me the following:

Traceback (most recent call last):
  File "<string>", line 4, in <module>

...***BUNCH OF STUFF I DELETED FROM ERROR MESSAGE***...

  RuntimeError: Object: Parameter index out of range for GetParameterAsText
1
  • 1
    Following up on Ron Santos answer, lynyrd's script is fine. Using the .GetParameterAsText() method implies that you're going to import the script to your toolbox and set up a parameter definition, so when you run the tool you're prompted for the output location of your choice. I'm new to this so I was confused at first by the same error. Found the (obvious in retrospect) solution in another post: community.esri.com/thread/29926 _(Hope I didn't break any major rules by adding another
    – Nathan
    May 21, 2020 at 20:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.