6

Is it possible to call an ArcPy script from a Java/.Net addin in ArcGIS 10.0?

Sunil
4,7737 gold badges44 silver badges89 bronze badges
asked Jan 18, 2013 at 6:45

2 Answers 2

6

Yes there are several ways to do this. I would recommend building a script tool and packaging it with your add-in. I have a sample project that does this listed in this answer: How can I programmatically get the path of "Python.exe" used by ArcMap

See also:

answered Jan 18, 2013 at 9:44
2

I call python script from my .net addin. I do it in a very simple way. I call it as I run process from .net code. Have a look at my code snippet

void RunPython(string scriptPath, string arguments)
{
 Process myProcess = new Process();
 try
 {
 myProcess.StartInfo.UseShellExecute = false;
 myProcess.StartInfo.RedirectStandardOutput = true;
 myProcess.StartInfo.FileName = "python";
 myProcess.StartInfo.Arguments = scriptPath + " " + arguments;
 myProcess.StartInfo.CreateNoWindow = true;
 myProcess.Start();
 string result = myProcess.StandardOutput.ReadToEnd();
 Console.WriteLine(result);
 }
 catch (Exception e)
 {
 Console.WriteLine(e.Message);
 }
 }
answered Jan 18, 2013 at 16:19
1
  • I do this myself to call a wxPython GUI from a .NET Add-In. Commented Jan 18, 2013 at 16:44

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.