Creating a Python extension for C# in VisualStudio?

01-07-2019 09:55 AM
New Contributor II

I'm developing an AddIn for ArcGISPro. Previously, in my python addin for ArcGIS 10.6, I use a great method to handle code changes on the fly: I use the regular python addin code (let's call it the 'pythonButtonWrapper') to:
- import a pythonModule.function code that runs when a particular button is clicked;
- 'recompile' that pythonModule code on the fly and;
- handle the button clicks, telling the pythonModule code what button was clicked.
The pythonModule code then takes over execution. It works great. Because I recompile the pythonModule code on the fly, I can code the functionality into the pythonModule code and never have to touch the pythonButtonWrapper. It never changes (unless of course I add new buttons, etc).

ArcGISPro uses Csharp for its addin code and I can generate a 'CsharpButtonWrapper' for it.
My question: how can I preserve the same functionality, calling my PYTHON module code functions from the 'CsharpButton Wrapper' that I get with VS 2017, passing in the button clicks? The last thing I want to do is translate all of the python module's code functionality into C#!

Note: I've found lots of on-line example code that calls python.exe from C# but that's NOT what I want to do. I need access to the python module functions themselves. Using IronPython in VS can work but then I don't have access to arcpy module calls because IronPython is a different runtime.

Thanks in advance for your helpful response,

0 Kudos
1 Reply
New Contributor II

Anyone want to take a shot at this? 🙂



0 Kudos