scribekey

command line interpreter in arcobjects batch

Discussion created by scribekey on Feb 6, 2011
Is there programmatic access to run the interpreter used behind the command line window in batch?

It would be useful to be able to run batch ArcObjects geoprocessing applications without having to create and populate a finer grained GeoProcessor object with tool name, input/output, parameters, etc, then execute.

So, you would just create something like script interpreter object in code, then just load and run a script text file. 

For example, if you had a simple script to run MultiPartToSinglePart tool, the command line input you see after running the tool is:

"MultipartToSinglepart Counties C:\MyGis\NewCounties.shp"

So, the c# psedocode for something like this would be:

...
ScriptProcesser scrProc = new ScriptProcessor();
scrProc.LoadScriptFile(@"c:\MyGis\MyScript.txt");
scrProc.Execute();
...

As the layer name "Counties" is available from the current .mxd context, you'd need to provide a full workspace spec, e.g.: 

MultipartToSinglepart C:\MyGis\Counties.shp C:\MyGis\NewCounties.shp

This would provide very flexible batch processing using only text files which would be very easy to generate from templates gotten by first running a tool manually. So, if you needed to do this 100 times, for 100 different layers, you could simply generate and run set of commands as lines of text, without having to create detailed GeoProcessor in code. The script file you'd create and run would look something like:

MultipartToSinglepart C:\MyGis\Layer1.shp C:\MyGis\NewLayer1.shp
MultipartToSinglepart C:\MyGis\Layer2.shp C:\MyGis\NewLayer2.shp
MultipartToSinglepart C:\MyGis\Layer3.shp C:\MyGis\NewLayer3.shp
...

Outcomes