Hi;
I am trying to create a new Pro Project from a previous template.
I have a couple questions:
I have included a couple screenshots of the Pro Project Catalog Pane after the script is completed and then once I manually add the new gdb connection.
I have also pasted my code below. I removed file paths as these are not pertinent for the issue.
Any help would be appreciated!
import arcpy
import os
import shutil
# Main Downloads
downloads_fol = r'C:\Users\rossch\Downloads'
# ArcGIS Prp template to copy
pro_template = r'FULL PATH TO PRO APRX TEMPLATE'
# Specify the ArcGIS Pro reference
pro_temp_aprx = arcpy.mp.ArcGISProject(pro_template)
# Ask the user for the Pro project name; set the new project path and save a copy
pro_name = input('Enter the name of the ArcGIS Pro folder and project to create: ')
# Specify the folder name and if it doesn't exist, create it
pro_prj_fol = os.path.join(downloads_fol, f'{pro_name}')
if not os.path.exists(pro_prj_fol):
os.mkdir(pro_prj_fol)
# Specify the new project name
new_pro_prj = os.path.join(pro_prj_fol, f'{pro_name}.aprx')
# Save a copy of the template ArcGIS Pro project
pro_temp_aprx.saveACopy(new_pro_prj)
# Clean up the original template ArcGIS Pro project
del pro_temp_aprx
# Set the new copied project as the ArcGIS Pro reference
main_aprx = arcpy.mp.ArcGISProject(new_pro_prj)
# Set the home folder
main_aprx.homeFolder = pro_prj_fol
# Create a new file geodatabase and make that the default gdb for the project
prj_gdb = os.path.join(pro_prj_fol, f'{pro_name}.gdb')
arcpy.CreateFileGDB_management(pro_prj_fol, f'{pro_name}.gdb')
main_aprx.defaultGeodatabase = prj_gdb
# Copy the template toolbox and make the default for the project
orig_tbx = r'FULL PATH TO TOOLBOX'
new_pro_tbx = os.path.join(pro_prj_fol, f'{pro_name}.atbx')
shutil.copy(orig_tbx, new_pro_tbx)
main_aprx.defaultToolbox = new_pro_tbx
# Save the project
main_aprx.save()
# Start the copied ArcGIS Pro project
os.startfile(new_pro_prj)
for the toolbox RemoveToolbox—ArcGIS Pro | Documentation
as for projects in general, you can create a template that creates new folders, gdb's and a toolbox or uses ones you specify (project backstage, options, General, Create Projects).
Would changing any of those when creating the project template help?
Appreciate the reply @DanPatterson.
Unfortunately, the Remove Toolbox geoprocessing tool only removes the Toolbox from the geoprocessing session and not from the ArcGIS Pro Project.
I am aware that you can set a pre-defined gdb, toolbox, etc. when Projects are created but then the copied Pro Project will just reference those and I am in the same boat.