Select to view content in your preferred language

Add a custom toolbox to many ArcGIS Pro projects (using python?)

246
2
05-14-2025 01:52 AM
Labels (2)
StephanieStedman
Emerging Contributor

So I have created a python script, now in a custom toolbox and I want to add this to a huge list of ArcGIS Projects (v. 3.0). Is there any way I can automate this, maybe through python? I would want to point a script at the windows folder containing the 100+ .aprx and get a script to run through all these projects and add the toolbox to the project for all .aprx within the folder.



I see there are commands such as ImportToolbox and AddToolbox but looks like these are to add your custom toolboxes into your python environment rather than save it into your Project?

For a bit more context, we run an ArcGIS Enterprise site and have many different Pro projects used for publishing all our services. I've created this python script which will make dated .mapx backups of our projects which I'd like people to start running before they make changes to the projects. Ideally I want to upload this toolbox into all of our existing projects so it's just there in the Catalogue Window ready for people to run, rather than everyone having to add it in themselves manually. I can add it to our template that we use for new Projects, but it’s getting into the mass of existing projects I’m struggling with.
I had a look at this, but wasn't sure if it would do what I wanted (I've made a toolbox rather than a python toolbox), we also do not have access to the C Drive for me to be able to add new tools there. 

https://support.esri.com/en-us/knowledge-base/how-to-create-and-store-a-custom-python-system-toolbox...

Or I've seen this example of adding a custom toolbox to a new ribbon, so this could be an option too if it can be saved into all the projects?  https://gis.stackexchange.com/questions/468634/how-to-add-a-custom-tool-to-arcgis-pro-tab-ribbon 


0 Kudos
2 Replies
JeffBarrette
Esri Regular Contributor

@StephanieStedman have you tried the following ArcGISProject members added at Pro 3.3.

- listToolboxes

- updateToolboxes()

https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/arcgisproject-class.htm

Adding folder connections and databases work the same.  Code Sample 4 in the link above.

A very simplified for adding a single toolbox is:

p = arcpy.mp.ArcGISProject('current')
tbxs = p.toolboxes
tbxs.append({'toolboxPath': r"C:\Temp\MyToolbox.atbx, 'isDefaultToolbox': False})
p.updateToolboxes(tbxs)

You could even start with an empty toolbox dictionary but be sure to make one (and only one) of them the default toolbox. 

Jeff - arcpy.mp team

StephanieStedman
Emerging Contributor

Thanks Jeff, this looks like it would be the solution, unfortunately I'm stuck at Pro 3.0 for now, but looking forward to trying this when we upgrade!

I've gone with creating a custom ribbon into Pro and adding my tool to that for now. (And getting my colleagues to use my same customisations file so they can have the same ribbon too).

0 Kudos