Please let me know, How to call
Please let me know, How to call Arc macro language script(AML for ARCGIS) from c# code.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Upamanyu Roy ChoudhuryPosted Feb 13, 2013, 4:18 AM
First make sure that the AML script can run from ARC.
Then using the below code to execute the command
public void ExecuteCommandSync(object command)
{
try
{
// create the ProcessStartInfo using "arc" as the program to be run,
// and "\"&run\"" as the parameters.
// Incidentally, "&run tells arc that we want it to execute the command that follows,
// and then exit.
// command is the "
System.Diagnostics.ProcessStartInfo procStartInfo =
new System.Diagnostics.ProcessStartInfo("arc", "\"&run\" " + command);
// The following commands are needed to redirect the standard output.
// This means that it will be redirected to the Process.StandardOutput StreamReader.
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
// Do not create the black window.
procStartInfo.CreateNoWindow = true;
// Now we create a process, assign its ProcessStartInfo and start it
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
// Get the output into a string
string result = proc.StandardOutput.ReadToEnd();
// Display the command output.
Console.WriteLine(result);
}
catch (Exception objException)
{
// Log the exception
}
}
Go through the link regarding how to excute the command in Code Project site
http://www.codeproject.com/Articles/25983/How-to-Execute-a-Command-in-C#
You might also find following links as useful
http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=using%20amls%20with%20script%20tools
http://forums.arcgis.com/threads/77382-Please-let-me-know-How-to-call-Arc-macro-language-script-from-c-code.?p=271715#post271715
http://www.esri.com/news/arcuser/0104/geoprocess.html
Regards,
Upamanyu
sameer khanPosted Feb 13, 2013, 12:11 AM
I got answer from below thread :-
http://forums.arcgis.com/threads/77382-Please-let-me-know-How-to-call-Arc-macro-language-script-from-c-code.?p=271715#post271715