Quite a vague question here but interested to hear some thoughts from ESRI and the community..
I have vague plans to move portions of our existing .NET SDK business logic into Python toolboxes for ease of distribution and sharing code between desktop and online. Also integration with the GP framework is a big plus.
Just wondering if there are any recommended practices I should follow here and if this approach is recommended at all.
Is there a standard way of distributing toolboxes within add-ins? Would they need to be packaged and distributed separately?
Or is there another recommended approach I should take entirely if I want to "share" query logic between my desktop and online apps? Are toolboxes the way to go?
This is certainly a supported approach if you want to include geoprocessing tools with your add-in. I have done this in a couple of my add-ins when I had existing geoprocessing tools that I leverage in other workflows but also want to invoke them from custom controls in the UI.
To package the toolbox with the add-in you will want to add the .pyt to your project, set the build action to 'None' and the Copy to Output Directory to 'Copy always'. When you build the project the toolbox will be packaged with the add-in along with your \assembly and any other dependencies.
In your add-in code you can then get the path to the toolbox on disk using the path of the executing assembly:
string installPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string toolboxPath = Path.Combine(installPath, "MyToolbox.pyt");
Thanks Chris this was just the reply I was hoping for - appreciated. On the subject of .NET vs ArcPy in Pro, would there be performance differences between to the two for say querying a table with a standard search cursor and returning some data?
I haven't done any performance testing in this regard, but my guess is it would be faster via .NET and the Pro api. This theory is simply based on the fact that there is some overhead in executing a GP tool. The things that are nice about GP such as parameter validation, messages, and cleanup when you are working with the tool through the UI can add a little time to each operation that you won't incur in .NET.
We have developed some custom python tools and created Conda package to distribute.
I want to distribute these tools in Marketplace,
My concern using above procedure is . there are many tools and they are dependent on third parry libraries, so I can't include all in "Build Action"
My Ides is to invoke conda package on add-in button click. How can I invoke "Conda install mytoolspkg" package from ArcGIS Pro add-in button click. i.e only first time, if the package is not installed.
Please suggest me what are the best options and share any related codes samples.