Embedding my custom toolbox within my ArcPro Add-In

323
5
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

Reply
0 Kudos
5 Replies
JoëlHempenius3
New Contributor III

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?

Reply
0 Kudos
CharlesMacleod
Esri 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). 

JoëlHempenius3
New Contributor III

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. 

Reply
0 Kudos
CharlesMacleod
Esri Contributor

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

Reply
0 Kudos
ThanHtetAung_EsriAu
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,

Than

Reply
0 Kudos