There should be a way to save the whole project as a new project, creating more than just the aprx file, but also duplicating all other supplemental files.
Have you looked at Set unpacking options?
This is great! Why isn't just choosing the output location just the default?
Oops, should have done my homework.
I think this idea is a duplicate (Ha-ha!) of this one. ArcGIS Pro: Save Project Copy - Page 2 - Esri Community
So, at the Dev Summit this last week, I asked about this.
The very nice Esri staff I was talking to was like "What are you talking about? Save As works fine"
So I say "No, it only duplicates the APRX but nothing else". So we test.
Turns out, in 3.2, the Save As functionality through the GUI has been changed to duplicate the entire folder. No clue as to whether it also duplicates the contents of your default GDB, but still, good to know.
I just tested it again in 3.1 and Save As only duplicates the APRX in this version.
Anyway, so it looks like there may be a viable solution out there. If someone using 3.2 could test and 1) confirm it actually works as it appeared to, as well as whether or not the contents of the Default GDB get duplicated, I'd appreciate it. (also what are the implications here for aprx.SaveACopy()?)
The other thing is: Why wasn't this change in behavior documented, either in the release notes or on one of the two relevant ideas (this one or this older one?) Very excited to hear there's light at the end of this particular tunnel, but I would never have found out if I hadn't asked directly.
Any update on this simple functionality that seems like a total no-brainer?
So, this is anecdotal since I'm still on 3.1, but in March I asked about this at the Dev Summit and got a "What are you talking about, Save As duplicates everything" and I was like "No it doesn't" and then they demoed it and it seems on 3.2 it works?
Can someone test this and let us know?
As it turns out, now that I'm in 3.3, Save As still only duplicates the APRX, so I'm not really sure what happened there.
We're trying to get the users to use PAGX and MAPX files, but it's an uphill battle.
When you use the "Save As" option currently, it creates a new .aprx file in the directory that you chose, but that .aprx file is still connected to everything in the old project. It does not have a folder connection to the new folder, it does not have a new file geodatabase (it is still connected to the previous project), and it does not get a tool box. In my opinion, this defeats the purpose of "Save As". When I use that option, I am looking to use my existing map to branch off into a new version, but retain my layouts, project data, etc..
It would make way more sense to me if "Save As" copied your project geodatabase and toolbox, as well as created a new folder connection to the new location rather than being completely tethered to the old project. Re-configuring all that takes so much time, I might as well have just started a new project from scratch.
Thanks @MDB_GIS for explaining it clearly. I had a similar need, and used this python toolbox as a workaround to make a clone of an ArcGIS Pro Project folder. Assuming that the .aprx, .gdb, and .tbx files all have the same name as the parent directory, you just give it in existing input folder, and the desired output folder. It will copy those 3 items (aprx, gdb, tbx) and update the default paths. It will also update the data sources for any layer that was pointing to the old gdb into the new gdb. It's not the most robust solution, but it worked for me.
I agree that this functionality should be native to ArcGIS Pro. Maybe another option next to "Save Project As" for "Clone Project"?
'''
This python toolbox will create a total copy of a Pro project (APRX with maps/layouts),
as well as the geodatabase and toolbox associated with it. The new project
will reference the new gdb/tbx copies. Data sources outside this gdb will not be updated.
This approach assumes that the parent directory, aprx, gdb and tbx files all have the same names (default Pro behavior)
It will not work if things have been renamed or moved around.
'''
import arcpy
import os
class Toolbox:
def __init__(self):
self.label = "Toolbox"
self.alias = "toolbox"
self.tools = [Tool]
class Tool:
def __init__(self):
self.label = "Save As Project Copy (Clone)"
self.description = ""
def getParameterInfo(self):
input_folder = arcpy.Parameter(
displayName="Input Folder",
name="input_folder",
datatype="DEFolder",
parameterType="Required",
direction="Input")
output_folder = arcpy.Parameter(
displayName="Output Folder",
name="output_folder",
datatype="DEFolder",
parameterType="Required",
direction="Output")
params = [input_folder, output_folder]
return params
def isLicensed(self):
return True
def updateParameters(self, parameters):
return
def updateMessages(self, parameters):
return
def execute(self, parameters, messages):
p = {p.name: p for p in parameters}
input_folder = p['input_folder'].valueAsText
output_folder = p['output_folder'].valueAsText
# define paths / variables for input and output dir/aprx/gdb/tbx
input_name = os.path.basename(input_folder)
input_project_path = os.path.join(input_folder, input_name+".aprx")
input_gdb_path = os.path.join(input_folder, input_name+".gdb")
input_tbx_path = os.path.join(input_folder, input_name+".atbx")
output_name = os.path.basename(output_folder)
output_project_path = os.path.join(output_folder, output_name+".aprx")
output_gdb_path = os.path.join(output_folder, output_name+".gdb")
output_tbx_path = os.path.join(output_folder, output_name+".atbx")
# Create the output folder if necessary
if not os.path.exists(output_folder):
os.makedirs(output_folder)
# Copy gdb and tbx
arcpy.management.Copy(input_gdb_path, output_gdb_path)
arcpy.management.Copy(input_tbx_path, output_tbx_path)
# Open the input project
p = arcpy.mp.ArcGISProject(input_project_path)
# Update data sources
p.updateConnectionProperties(input_gdb_path,output_gdb_path)
for map_ in p.listMaps():
for layer in map_.listLayers():
if layer.supports("dataSource"):
layer.updateConnectionProperties(input_gdb_path, output_gdb_path)
# Update project defaults
p.defaultGeodatabase = output_gdb_path
p.defaultToolbox = output_tbx_path
p.homeFolder = output_folder
# Save a copy of the modified input aprx as the output aprx
p.saveACopy(output_project_path)
return
def postExecute(self, parameters):
return
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.