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.

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);
share|improve this question
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
add comment

2 Answers 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);
share|improve this answer
    
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
add comment
up vote 2 down vote accepted

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.

share|improve this answer
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.