Overwrite for exportToPAGX

938
6
05-18-2022 04:48 PM
Status: Implemented
Labels (1)
BrettFrahm
Occasional Contributor II

Arcpy.mp's exportToPAGX is currently unable to export as an overwrite. Use .pagxs to store layouts and need to be able to overwrite with this function. 

 

When attempting to exportToPAGX() with the same filepath as another .pagx in that folder, I get this error:

<module>
layout.exportToPAGX(out_pagx=OutputExport)
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py", line 1526, in exportToPAGX
return convertArcObjectToPythonObject(self._arc_object.exportToPAGX(*gp_fixargs((out_pagx,), True)))
RuntimeError: Failed to export pagx to path: "......."

6 Comments
JeffBarrette
Status changed to: Needs Clarification

Hi Brett,

I can not reproduce this either as in-process (i.e., 'current') or as a stand-alone script. I tested 2.9 and 3.0. Can you still reproduce?  If you still can, did you try the GP env setting OverWriteOuput?

Here is a simple script that works.  And it works if I close and reopen and/or run again.

import arcpy
p = arcpy.mp.ArcGISProject(r"C:\temp\GreatLakes\GreatLakes.aprx")  #or 'current'
lyt = p.listLayouts('Layout')[0]
lyt.exportToPAGX(r"C:\Temp\Layout.pagx")
lyt.exportToPAGX(r"C:\Temp\Layout.pagx")
lyt.exportToPAGX(r"C:\Temp\Layout2.pagx")
lyt.exportToPAGX(r"C:\Temp\Layout3.pagx")

JeffBarrette
Status changed to: Closed

Closed pending response. We can re-assess once we have more information"

Jeff - Layout and arcpy.mp teams 

BrettFrahm

Hey @JeffBarrette,

 

It was my mistake. The file extension was not included which caused it to error out. The other export functions like .exportToPDF() do not require the file extension which is why I wasn't sure what was causing the issue.

JeffBarrette

Thanks Brett for clarifying the issue.  I was able to reproduce your issue and submitted a bug.  I noticed that with map.exportToMAPX doesn't throw an error but I don't think the export happens - at least the timestamp isn't updated.

exportToPDF(r"C:\Temp\ABC")

exportToPDF(r"C:\Temp\ABC")

Auto creates the .pdf ext, overwrites output and updates the timestamp.

We will make the export experience similar.

Thanks again,

Jeff - Layout and arcpy.mp teams

JeffBarrette
Status changed to: In Product Plan

We are testing a fix for this issue for ArcGIS Pro version 3.1

AmeliaBradshaw
Status changed to: Implemented

This Idea has been implemented in ArcGIS Pro 3.1. Please see the What's New documentation for more new features in Pro 3.1.

The Ideas in ArcGIS Pro 3.1 blog will be wrapped up soon, highlighting all Ideas implemented in this release, including this one. Once complete, I will add the link to this comment.