<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Exporting layout file from ArcGIS Pro project to *.pagx file using ArcPy? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/exporting-layout-file-from-arcgis-pro-project-to/m-p/612240#M47775</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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&amp;nbsp;ArcGIS Pro GUI,&amp;nbsp;but I'm struggling to find a way to export these files via&amp;nbsp;ArcPy.&lt;/P&gt;&lt;P&gt;So far I used the following code to modify layout from the individual *.pagx file:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
layout &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mp&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ConvertLayoutFileToLayout&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;"C:\temp\templates\8x11 Landscape.pagx"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; element &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; layout&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;listElements&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'TEXT_ELEMENT'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
 &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; element&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'Text 4'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
 element&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;text &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"New text"&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but there is no way to save the modified&amp;nbsp;layout&amp;nbsp;object as a file. Also I tried to loop through the layouts, imported to the Pro project&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;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()&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 02:11:21 GMT</pubDate>
    <dc:creator>NikolayGolosov</dc:creator>
    <dc:date>2021-12-12T02:11:21Z</dc:date>
    <item>
      <title>Exporting layout file from ArcGIS Pro project to *.pagx file using ArcPy?</title>
      <link>https://community.esri.com/t5/python-questions/exporting-layout-file-from-arcgis-pro-project-to/m-p/612240#M47775</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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&amp;nbsp;ArcGIS Pro GUI,&amp;nbsp;but I'm struggling to find a way to export these files via&amp;nbsp;ArcPy.&lt;/P&gt;&lt;P&gt;So far I used the following code to modify layout from the individual *.pagx file:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
layout &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mp&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ConvertLayoutFileToLayout&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;"C:\temp\templates\8x11 Landscape.pagx"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; element &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; layout&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;listElements&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'TEXT_ELEMENT'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
 &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; element&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'Text 4'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
 element&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;text &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"New text"&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but there is no way to save the modified&amp;nbsp;layout&amp;nbsp;object as a file. Also I tried to loop through the layouts, imported to the Pro project&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;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()&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:11:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporting-layout-file-from-arcgis-pro-project-to/m-p/612240#M47775</guid>
      <dc:creator>NikolayGolosov</dc:creator>
      <dc:date>2021-12-12T02:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting layout file from ArcGIS Pro project to *.pagx file using ArcPy?</title>
      <link>https://community.esri.com/t5/python-questions/exporting-layout-file-from-arcgis-pro-project-to/m-p/612241#M47776</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tried to employ jsontocim module, located in&amp;nbsp;"C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\cim\cimloader\jsontocim.py"&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;from arcpy.mp import ConvertLayoutFileToLayout
from arcpy.cim.cimloader.cimtojson import CimJsonEncoder
from json import dumps

layout = ConvertLayoutFileToLayout(r"C:\temp\templates\8x11 Landscape.pagx")
cim = layout.getDefinition('V2')
outJSON = dumps(cim, cls=CimJsonEncoder, indent=2)
print(outJSON)&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.5pt; color: #3d3d3d;"&gt;It produced the output, resembling the structure of the *.pagx file,&amp;nbsp;&lt;/SPAN&gt;exported&amp;nbsp;via GUI, but some parts are missing, and some of them have a different structure, so I were unable to import this file back to ArcGIS Pro.&amp;nbsp;I'd be glad if&amp;nbsp;anyone advice if there is any way to use that approach(with CimJsonEncoder) to receive a valid pagx JSON file?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:11:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporting-layout-file-from-arcgis-pro-project-to/m-p/612241#M47776</guid>
      <dc:creator>NikolayGolosov</dc:creator>
      <dc:date>2021-12-12T02:11:24Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting layout file from ArcGIS Pro project to *.pagx file using ArcPy?</title>
      <link>https://community.esri.com/t5/python-questions/exporting-layout-file-from-arcgis-pro-project-to/m-p/612242#M47777</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Any thoughts on that?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Sep 2019 16:32:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporting-layout-file-from-arcgis-pro-project-to/m-p/612242#M47777</guid>
      <dc:creator>NikolayGolosov</dc:creator>
      <dc:date>2019-09-05T16:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting layout file from ArcGIS Pro project to *.pagx file using ArcPy?</title>
      <link>https://community.esri.com/t5/python-questions/exporting-layout-file-from-arcgis-pro-project-to/m-p/612243#M47778</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm also&amp;nbsp;needing to do this.&lt;/P&gt;&lt;P&gt;What's needed is a method to make a copy of a existing layout/ 'save as' is required to make the most of automated map production.&lt;/P&gt;&lt;P&gt;For example, I have a tool which takes an input layout in a project and updates it (i.e. the extent, layout text elements etc). This is considered the 'parent' map.&lt;/P&gt;&lt;P&gt;There may be multiple 'children' of that 'parent' and I want the second tool to save a copy of the 'parent' layout (including any information that has been added in the first tool), then manipulate it and save it/add it to the current project.&lt;/P&gt;&lt;P&gt;So, something like a&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;for layout in aprx.listLayouts("Layout Parent")[0]:
&amp;nbsp;&amp;nbsp;&amp;nbsp;layout.saveAs('pathtoChild1.pagx', "Updated Layout name")

&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:11:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporting-layout-file-from-arcgis-pro-project-to/m-p/612243#M47778</guid>
      <dc:creator>GeoNZ</dc:creator>
      <dc:date>2021-12-12T02:11:27Z</dc:date>
    </item>
  </channel>
</rss>

