3

I created a custom geoprocessing tool called "CreateCoverLayer". It has no input or output parameters. I have the following snippet of code, but get an error message due to the fact that the Execute method is looking for an array of parameters as the second input argument. Can I use this tool with no parameters, or is that not possible? Thanks!

IGeoProcessor2 gp = new GeoProcessorClass();    
gp.AddToolbox(@"C:\TestToolbox.tbx");
gp.Execute("CreateCoverLayer", null, null);
  • 1
    Did you try passing an empty array? – Kirk Kuykendall May 24 '13 at 18:54
  • Yes, I also tried this . . . – Renee Cammarere May 24 '13 at 19:10
  • IGeoProcessor2 gp = new GeoProcessorClass(); gp.AddToolbox(@"C:\TestToolbox.tbx"); IVariantArray parameters = new VarArrayClass();gp.Execute("CreateCoverLayer", parameters, null); – Renee Cammarere May 24 '13 at 19:11
  • 1
    That should work. What happens when you use an empty IVariantArray? – blah238 May 25 '13 at 4:10
  • The above code (sending in the empty array) did work, so I'm all set. – Renee Cammarere May 29 '13 at 14:21
2

Try using the geoprocessor managed assembly instead of the geoprocessing one. You can call execute without a parameter variable, as shown with the system delete below, but im not sure what it will do with a custom tool.

Geoprocessor gp = new Geoprocessor();
DeleteFeatures delete = new DeleteFeatures();
delete.in_features = layer;
gp.Execute(delete, null);
  • Yes, I've also used this type of code and was successful . . . – Renee Cammarere May 29 '13 at 14:25
  • ESRI.ArcGIS.Geoprocessor.Geoprocessor GP = new ESRI.ArcGIS.Geoprocessor.Geoprocessor(); CopyFeatures copyFeatures = new CopyFeatures(); copyFeatures.in_features = @"C:\FOBSP.gdb\BrigadeAOI"; copyFeatures.out_feature_class = @"C:\Data\BrigadeAOIcopy.shp"; RunTool(GP, copyFeatures, null); – Renee Cammarere May 29 '13 at 14:28
2

The following code did work . . .

IGeoProcessor2 gp = new GeoProcessorClass(); 
gp.AddToolbox(@"C:\TestToolbox.tbx"); 
IVariantArray parameters = new VarArrayClass();
gp.Execute("CreateCoverLayer", parameters, null); 

Sending in the empty array did the trick.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.