Embedding my custom toolbox within my ArcPro Add-In

06-08-2020 04:23 AM
by Anonymous User
Not applicable

It's my first time posting on here so I am sorry if I don't correctly format this question.

I have been building an ArcPro Add-In and I wanted to embed a toolbox so that when I send the add-in to the client I am able to source the path to the toolbox and then open it from a ribbon button. I followed the suggestions in this question but when I install the toolbox to ArcPro it doesn't create the toolbox folders within the AppData directory. When I check inside the add-inX file I can see the custom toolbox within there in the file structure shown in the previously asked question. I am wondering why when installing the Add-in does it not create the toolbox folder within appdata? I must be doing something wrong but I can't figure it out (I am fairly new to c# and add-in creation so that is probably where I am stumbling)

Any help would be appreciated and here are some images of the visual studio menu and the esri addinX file

0 Kudos
6 Replies
Occasional Contributor

Hi Jack,

I had the same problem this morning with my Add-In and a custom .pyt toolbox with ArcGIS 2.5 and 2.6.

However, the toolbox was visible in the list of toolboxes in ArcGIS Pro. Which made me wonder where my script was placed.

I therefore added:
arcpy.AddMessage("Script {0} loaded".format(os.path.dirname(os.path.realpath(__file__))))

to my execute function in the toolbox and got the path of my script. 

The structure of my VS project looks like this:

When I go to my App data folder after deploying the Add-In and the Add-In is active in ArcGIS Pro I see this:

The Toolboxes folder is just like your description not visible. (note that Hidden Items should be visible)

However, when I open the path from the Python Message I can go into the directory and I see the toolboxes subdirectory.

So maybe the directory is also there in your case but for unknown reasons not visible?

Uma Harano‌, can you take a look at this?

-Joël Hempenius.

Languages: JavaScript, Python and Dunglish
0 Kudos
Esri Regular Contributor

The add-in must be loaded. (Step 10). The toolbox folder is not deployed on install.

When Pro shuts down the folder remains. _However_, if:

either - the add-in is uninstalled

or - the add-in is not loaded the next time Pro starts (eg security settings were changed)

the toolboxes folder will be deleted.....

So even though the folder may be present on the disk between Pro sessions, if the accompanying add-in is not loaded for the session then neither will its toolbox. This is mentioned under the "Note:" at the bottom of the previously referenced article. 

I suspect the confusion is arising from examining the assembly cache location of a previously loaded add-in where the toolboxes folder would be present (if it had an embedded toolbox) and comparing it with the assembly cache location of an add-in with an embedded toolbox that has not (been loaded). 

Occasional Contributor

Hi Charles,

The Add-in was loaded in my case, the screenshots from Windows Explorer were made with ArcGIS Pro active with the Add-In toolbar visible. I edited my answer, becauseI forgot to mention this. 

-Joël Hempenius.

Languages: JavaScript, Python and Dunglish
0 Kudos
Esri Regular Contributor

Thanks for this Joel. This could be a bug then. Could you make a repro available to tech support so we can debug?

0 Kudos
Esri Regular Contributor

Hi Jack Bestard‌,

I have this kind of usecase before and manage to solve it before.

Two steps 

Step 1: Change your toolbox file properties into 

   Build Action : None

   Copy to Output Directory : Copy Always

Step 2 : at C# coding part : how to retrieve the toolbox, in your project you store at "\toolboxes\toolboxes\InSar_Analyst.tbx"

So the example code snippet for your toolbox file path is 

string assemblyfolderpath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string fulltoolfilepath= System.IO.Path.Combine(assemblyfolderpath, @"toolboxes\toolboxes\InSar_Analyst.tbx");‍‍

Best Regards,


0 Kudos
by MVP Regular Contributor
MVP Regular Contributor

Looks like the same issue is still happening. On my machine, the 'ToolBoxes' folder is not shown in the C:\Users\me\AppData\Local\ESRI\ArcGISPro\ folder, but I can get to it/ move in and out of it if I copy paste into windows explorer. The embedded toolbox doesn't show in the list of Toolboxes in Pro either. It only creates the guid folder if I add a folder with arcpy (a module) to the VS project. The python module I attempted to create following an esri example infected my other python environments and is causing AttributeError: module 'TbleCounts' has no attribute '__alias__' errors, regardless of python environment. During debugging its trying to load from the module from the {guid}\arcpy\__init__.py path.  This isn't going to work...

I need the custom toolbox (containing toolsets) embedded (along with a custom python env clone) to be packaged together in a single add-in, and preferably the toolbox listed under the Projects Toolbox folder.  I'm going to start another topic- According to the pro guide example, I should be able to embed a custom toolbox, but it is not working as it is described.

0 Kudos