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.

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

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

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:

share|improve this answer
add comment

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);
        }
 }
share|improve this answer
    
I do this myself to call a wxPython GUI from a .NET Add-In. –  Chad Cooper Jan 18 '13 at 16:44
add comment

Your Answer

 
discard

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.