Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Are there any available examples that show how python can be integrated into a .NET ArcGIS Addin or Extension? I have a series of python scripts that I would like to call from form events (e.g. button clicks) in .NET. I would also like to be able to set variables in the script from a .NET form.

Should I bite the bullet and re-write these scripts in .NET, or is there a simple way to wrap the python code?

share|improve this question
up vote 24 down vote accepted

Keep in mind that Arcpy is essentially a wrapper around ArcObjects. But if you're just trying to call some Python scripts that you don't want to have to rewrite you can spawn a process that calls the python executable with your args.

var startInfo = new ProcessStartInfo() {
   CreateNoWindow = false,
   UseShellExecute = false,
   FileName = pathToPythonRuntime,
   WindowStyle = ProcessWindowStyle.Hidden,
   Arguments = pathToYourPythonScriptYouDoNotWantToRewrite+" "+yourOtherArgsEtc
var exeProcess= Process.Start(startInfo);
//If you need synchronous execution you can do this

Note that you can do some pretty cool multithreading stuff with this too.

share|improve this answer
Perfect - thanks for the quick response. – Radar Jan 12 '12 at 18:53

From your Question I am not sure how wedded to .NET you are but, if you are using ArcGIS 10.1 (or later) for Desktop, then I think a simpler approach will be to use a Python AddIn:

ArcGIS 10.1 introduces Python to the list of languages for authoring Desktop add-ins, providing you with an easy solution to extend desktop functionality. To simplify the development of Python add-ins, you must download and use the Python Add-In Wizard to declare the type of customization. The wizard will generate all the required files necessary for the add-in to work.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.