<?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 Arcpy Mapping in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-mapping/m-p/1244159#M66350</link>
    <description>&lt;P&gt;Hi;&lt;/P&gt;&lt;P&gt;I am trying to create a new Pro Project from a previous template.&lt;/P&gt;&lt;P&gt;I have a couple questions:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;When I update the default toolbox, it gets added to the project as default but the old toolbox is still there referenced. Is there any way to remove it in Python without deleting it?&lt;/LI&gt;&lt;LI&gt;Similar to above, when I updated the Home Folder, it gets added but the old folder is still there.&amp;nbsp;Is there any way to remove it in Python without deleting it?&lt;/LI&gt;&lt;LI&gt;My main concern, when I update the default database, it does not show initially and is not added automatically to the list of databases. Is there anyway to add it via Python and remove the old one, without deleting it? When I add the new default database connection manually it does show it is the default gdb.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;I have also pasted my code below. I removed file paths as these are not pertinent for the issue.&lt;/P&gt;&lt;P&gt;Any help would be appreciated!&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;arcpy&lt;BR /&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;os&lt;BR /&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;shutil&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Main Downloads&lt;BR /&gt;&lt;/SPAN&gt;downloads_fol = &lt;SPAN&gt;r'C:\Users\rossch\Downloads'&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;# ArcGIS Prp template to copy&lt;BR /&gt;&lt;/SPAN&gt;pro_template = &lt;SPAN&gt;r'FULL PATH TO PRO APRX TEMPLATE'&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;# Specify the ArcGIS Pro reference&lt;BR /&gt;&lt;/SPAN&gt;pro_temp_aprx = arcpy.mp.ArcGISProject(pro_template)&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Ask the user for the Pro project name; set the new project path and save a copy&lt;BR /&gt;&lt;/SPAN&gt;pro_name = &lt;SPAN&gt;input&lt;/SPAN&gt;(&lt;SPAN&gt;'Enter the name of the ArcGIS Pro folder and project to create: '&lt;/SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Specify the folder name and if it doesn't exist, create it&lt;BR /&gt;&lt;/SPAN&gt;pro_prj_fol = os.path.join(downloads_fol, &lt;SPAN&gt;f'&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;pro_name&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;)&lt;BR /&gt;&lt;SPAN&gt;if not &lt;/SPAN&gt;os.path.exists(pro_prj_fol):&lt;BR /&gt;    os.mkdir(pro_prj_fol)&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Specify the new project name&lt;BR /&gt;&lt;/SPAN&gt;new_pro_prj = os.path.join(pro_prj_fol, &lt;SPAN&gt;f'&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;pro_name&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;.aprx'&lt;/SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Save a copy of the template ArcGIS Pro project&lt;BR /&gt;&lt;/SPAN&gt;pro_temp_aprx.saveACopy(new_pro_prj)&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Clean up the original template ArcGIS Pro project&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;del &lt;/SPAN&gt;pro_temp_aprx&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Set the new copied project as the ArcGIS Pro reference&lt;BR /&gt;&lt;/SPAN&gt;main_aprx = arcpy.mp.ArcGISProject(new_pro_prj)&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Set the home folder&lt;BR /&gt;&lt;/SPAN&gt;main_aprx.homeFolder = pro_prj_fol&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Create a new file geodatabase and make that the default gdb for the project&lt;BR /&gt;&lt;/SPAN&gt;prj_gdb = os.path.join(pro_prj_fol, &lt;SPAN&gt;f'&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;pro_name&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;.gdb'&lt;/SPAN&gt;)&lt;BR /&gt;arcpy.CreateFileGDB_management(pro_prj_fol, &lt;SPAN&gt;f'&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;pro_name&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;.gdb'&lt;/SPAN&gt;)&lt;BR /&gt;main_aprx.defaultGeodatabase = prj_gdb&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Copy the template toolbox and make the default for the project&lt;BR /&gt;&lt;/SPAN&gt;orig_tbx = &lt;SPAN&gt;r'FULL PATH TO TOOLBOX'&lt;BR /&gt;&lt;/SPAN&gt;new_pro_tbx = os.path.join(pro_prj_fol, &lt;SPAN&gt;f'&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;pro_name&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;.atbx'&lt;/SPAN&gt;)&lt;BR /&gt;shutil.copy(orig_tbx, new_pro_tbx)&lt;BR /&gt;main_aprx.defaultToolbox = new_pro_tbx&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Save the project&lt;BR /&gt;&lt;/SPAN&gt;main_aprx.save()&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Start the copied ArcGIS Pro project&lt;BR /&gt;&lt;/SPAN&gt;os.startfile(new_pro_prj)&lt;/PRE&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 29 Dec 2022 02:26:31 GMT</pubDate>
    <dc:creator>ChrisJRoss13</dc:creator>
    <dc:date>2022-12-29T02:26:31Z</dc:date>
    <item>
      <title>Arcpy Mapping</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping/m-p/1244159#M66350</link>
      <description>&lt;P&gt;Hi;&lt;/P&gt;&lt;P&gt;I am trying to create a new Pro Project from a previous template.&lt;/P&gt;&lt;P&gt;I have a couple questions:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;When I update the default toolbox, it gets added to the project as default but the old toolbox is still there referenced. Is there any way to remove it in Python without deleting it?&lt;/LI&gt;&lt;LI&gt;Similar to above, when I updated the Home Folder, it gets added but the old folder is still there.&amp;nbsp;Is there any way to remove it in Python without deleting it?&lt;/LI&gt;&lt;LI&gt;My main concern, when I update the default database, it does not show initially and is not added automatically to the list of databases. Is there anyway to add it via Python and remove the old one, without deleting it? When I add the new default database connection manually it does show it is the default gdb.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;I have also pasted my code below. I removed file paths as these are not pertinent for the issue.&lt;/P&gt;&lt;P&gt;Any help would be appreciated!&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;arcpy&lt;BR /&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;os&lt;BR /&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;shutil&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Main Downloads&lt;BR /&gt;&lt;/SPAN&gt;downloads_fol = &lt;SPAN&gt;r'C:\Users\rossch\Downloads'&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;# ArcGIS Prp template to copy&lt;BR /&gt;&lt;/SPAN&gt;pro_template = &lt;SPAN&gt;r'FULL PATH TO PRO APRX TEMPLATE'&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;# Specify the ArcGIS Pro reference&lt;BR /&gt;&lt;/SPAN&gt;pro_temp_aprx = arcpy.mp.ArcGISProject(pro_template)&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Ask the user for the Pro project name; set the new project path and save a copy&lt;BR /&gt;&lt;/SPAN&gt;pro_name = &lt;SPAN&gt;input&lt;/SPAN&gt;(&lt;SPAN&gt;'Enter the name of the ArcGIS Pro folder and project to create: '&lt;/SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Specify the folder name and if it doesn't exist, create it&lt;BR /&gt;&lt;/SPAN&gt;pro_prj_fol = os.path.join(downloads_fol, &lt;SPAN&gt;f'&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;pro_name&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;)&lt;BR /&gt;&lt;SPAN&gt;if not &lt;/SPAN&gt;os.path.exists(pro_prj_fol):&lt;BR /&gt;    os.mkdir(pro_prj_fol)&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Specify the new project name&lt;BR /&gt;&lt;/SPAN&gt;new_pro_prj = os.path.join(pro_prj_fol, &lt;SPAN&gt;f'&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;pro_name&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;.aprx'&lt;/SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Save a copy of the template ArcGIS Pro project&lt;BR /&gt;&lt;/SPAN&gt;pro_temp_aprx.saveACopy(new_pro_prj)&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Clean up the original template ArcGIS Pro project&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;del &lt;/SPAN&gt;pro_temp_aprx&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Set the new copied project as the ArcGIS Pro reference&lt;BR /&gt;&lt;/SPAN&gt;main_aprx = arcpy.mp.ArcGISProject(new_pro_prj)&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Set the home folder&lt;BR /&gt;&lt;/SPAN&gt;main_aprx.homeFolder = pro_prj_fol&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Create a new file geodatabase and make that the default gdb for the project&lt;BR /&gt;&lt;/SPAN&gt;prj_gdb = os.path.join(pro_prj_fol, &lt;SPAN&gt;f'&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;pro_name&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;.gdb'&lt;/SPAN&gt;)&lt;BR /&gt;arcpy.CreateFileGDB_management(pro_prj_fol, &lt;SPAN&gt;f'&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;pro_name&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;.gdb'&lt;/SPAN&gt;)&lt;BR /&gt;main_aprx.defaultGeodatabase = prj_gdb&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Copy the template toolbox and make the default for the project&lt;BR /&gt;&lt;/SPAN&gt;orig_tbx = &lt;SPAN&gt;r'FULL PATH TO TOOLBOX'&lt;BR /&gt;&lt;/SPAN&gt;new_pro_tbx = os.path.join(pro_prj_fol, &lt;SPAN&gt;f'&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;pro_name&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;.atbx'&lt;/SPAN&gt;)&lt;BR /&gt;shutil.copy(orig_tbx, new_pro_tbx)&lt;BR /&gt;main_aprx.defaultToolbox = new_pro_tbx&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Save the project&lt;BR /&gt;&lt;/SPAN&gt;main_aprx.save()&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Start the copied ArcGIS Pro project&lt;BR /&gt;&lt;/SPAN&gt;os.startfile(new_pro_prj)&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 29 Dec 2022 02:26:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping/m-p/1244159#M66350</guid>
      <dc:creator>ChrisJRoss13</dc:creator>
      <dc:date>2022-12-29T02:26:31Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy Mapping</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping/m-p/1244160#M66351</link>
      <description>&lt;P&gt;for the toolbox&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/removetoolbox.htm" target="_blank"&gt;RemoveToolbox—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;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).&lt;/P&gt;&lt;P&gt;Would changing any of those when creating the project template help?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Dec 2022 03:08:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping/m-p/1244160#M66351</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-12-29T03:08:16Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy Mapping</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping/m-p/1244177#M66352</link>
      <description>&lt;P&gt;Appreciate the reply&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/215600"&gt;@DanPatterson&lt;/a&gt;.&lt;/P&gt;&lt;P&gt;Unfortunately, the Remove Toolbox geoprocessing tool only removes the Toolbox from the geoprocessing session and not from the ArcGIS Pro Project.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Dec 2022 10:19:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping/m-p/1244177#M66352</guid>
      <dc:creator>ChrisJRoss13</dc:creator>
      <dc:date>2022-12-29T10:19:29Z</dc:date>
    </item>
  </channel>
</rss>

