Select to view content in your preferred language

How to call an ArcGIS Pro SDK (C#) Add-in project from Python ?

2689
6
09-07-2018 09:09 AM
FabianOrtega
Occasional Contributor

Hi ! I created an Add-in project using the ArcGIS Pro SDK for .NET (C#) and now I'm trying to call the Add-in methods from my Python scripts using ArcPy but I didn't find neither documentation nor examples how to achieve this, I've tried some things however it didn't work and now I'm stuck... So I'm wondering if someone knows or has any ideas how to do this ?

Thank you.

6 Replies
CharlieGorman
Emerging Contributor

What type of functionality is in your C# code that you would like to call from Python?

A more typical code pattern would be to have C# code call Python using the Geoprocessing API as demonstrated in this sample:

Github Esri/arcgis-pro-sdk-community-samples: CallScriptFromNet 

FabianOrtega
Occasional Contributor

Hi Charlie!

 

Actually all our production line is based on ArcPy scripts, however we’re using ArcGIS Pro SDK for .Net (C#) for one specific functionality that can’t be done with ArcPy: export the annotations baselines (the polylines not the bounding box polygons) into a new Feature Class, that’s why we need to call C# code from Python.

 

So the functionalities that have been implemented in C# are:

  1. Retrieve the annotations baselines and the attributs from a given Annotation Layer
  2. Create a new Feature Class
  3. Insert the annotations baselines and the attributs into the new Feature Class

 

Would you have any idea how we could accomplish this?

 

Thank you for your attention to this matter. Best regards.

MarvisKisakye1
Regular Contributor

Did you ever find out if there's a way to call an ArcGIS Pro SDK Add-in from a python script? Charlie Gorman

FabianOrtega
Occasional Contributor

Hi !

Currently there's no way to call an ArcGIS Pro SDK Add-In from a python script.

So, I implemented a workaround: I created a Console Application, which will be called from a python script, like an entry-point.

Note: This workaround only works if you're working with "ArcGIS.Core" and "ArcGIS.Corehost" assemblies, it crashes for all the other assemblies (ArcGIS.Desktop.*)

Cheers,

ThomasCrossman
Occasional Contributor

Could the Python.NET module (pythonnet) be of any help?  (Old post, I know, but thought I'd mention it.)

MarianneRohrbach
Occasional Contributor

We are now struggling with the same question and we would solve it the same way, as you did, Fabian.

I expected at least to be able to create a C#/.net-GP Tool to call it from python. I cannot understand, why this isn't supported in the Pro SDK.
Also nice would be to enable ArcGIS Pro command search and execution from python script.

It really does not make sense to call Python Script from C#/.net Code. Scripts are used to automate things, C#/.net to implement functions.

I picked this up to hopefully draw other customers and esri's attention to it.

Thanks for this post, Fabian and kind regards