Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 22 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
add comment

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.