AnsweredAssumed Answered

Exporting layout file from ArcGIS Pro project to *.pagx file using ArcPy?

Question asked by golosov on Aug 12, 2019
Latest reply on Oct 29, 2019 by NZGeoCAD

I'm trying to implement a tool to import *.pagx files exported from ArcGIS Pro to a project, modify text elements and export the altered layouts back to the *.pagx files. It is pretty easy to export these files via ArcGIS Pro GUI, but I'm struggling to find a way to export these files via ArcPy.

So far I used the following code to modify layout from the individual *.pagx file:

import arcpy
layout = arcpy.mp.ConvertLayoutFileToLayout(r"C:\temp\templates\8x11 Landscape.pagx")
for element in layout.listElements('TEXT_ELEMENT'):
if element.name == 'Text 4':
element.text = "New text"

but there is no way to save the modified layout object as a file. Also I tried to loop through the layouts, imported to the Pro project

import arcpy
aprx = arcpy.mp.ArcGISProject(r"C:\Users\username\Documents\ArcGIS\Projects\Layouts\Layouts.aprx")
for layout in aprx.listLayouts():
for element in layout.listElements('TEXT_ELEMENT'):
if element.name == 'Text 4':
element.text = "New text"
aprx.save()

Using the save() method I can save the project, but again there is no way to export the *.pagx files. I heard somewhere that I could export these *.pagx files via the .Net API only, but I'm still not 100% sure if such export feature is not implemented in arcpy, or I overlooked something. 

Outcomes