Hi,
I've encountered weird behaviour in the saveACopy method of the arcpy.mp.ArcGISProject class. It seems that it modifies the value of "CURRENT". I've assembled a short code sample:
import arcpy
def PrintFilePathOfCurrentArcGISProject(msg):
# Open the "CURRENT" project and print the file path
aprx = arcpy.mp.ArcGISProject("CURRENT")
arcpy.AddMessage(f"{msg}: {aprx.filePath}")
def main():
PrintFilePathOfCurrentArcGISProject("Before opening \"CURRENT\" aprx")
aprx = arcpy.mp.ArcGISProject("CURRENT")
aprx.saveACopy(r"D:\test_copy.aprx")
PrintFilePathOfCurrentArcGISProject("After saveACopy")
if __name__ == "__main__":
main()
When running the script in ArcGIS Pro 2.9.3, the output is:
Before opening "CURRENT" aprx: C:\Users\Madlener\Documents\ArcGIS\Projects\MyProject\MyProject.aprx
After saveACopy: D:\test_copy.aprx
I wonder if this is a bug (I certainly think it is one..) If it's not a bug, this behaviour should be documented in the saveACopy method. The problem is that I cannot restore the old value of "CURRENT" by any means. If there's a way though, I'd be glad if somebody could let me know.
Thanks in advance
Christian