4

I am executing the copy features tool via the geoprocessor inside my .net custom geoprocessing function tool. When the copy features tool executes it is writing it's messages to my tool's results. I want to stop these messages from being written and handle them myself. Is there a way to stop a geoprocessor from writing messages? I am writing .net on 10.1.

This is the code I am running the tool with.

            IGeoProcessor2 gp = new GeoProcessorClass();
            IGeoProcessorResult results = new GeoProcessorResultClass();
            IVariantArray parameters = new VarArrayClass();
            parameters.Add(tempFC);
            parameters.Add(outFC);
            results = gp.Execute("CopyFeatures_Management", parameters, null);
1

3 Answers 3

1

Gus,

I've not tested this but there is an interface called IGeoProcessorSettings2 which has a LogHistory property which you can set to false.

Failing that you could call the IGeoProcessor2 method ClearMessages to blitz everything?

1
  • Thanks, that looked really promising. I tried setting IGeoProcessorSettings2 LogHistory to false but the message still posted to my tools dialog. I then tried ClearMessages. It cleared the messages from the IGPMessages but not before the message posted to my tools dialog.
    – TurboGus
    Commented May 29, 2013 at 15:49
0

You can always get an instance of the particular IGPFunction and execute it yourself. It is less convenient than using the IGeoProcessor since it requires you to handle the input and output parameters all yourself (which you probably know how to do if you develop your own tool), but it also allows you to have full control over the messages the tool produces.

0

The solution was to set IGeoProcessor2.AddToResults to false.

Something like

 IGeoProcessor2 gp = new GeoProcessorClass();

 gp.AddToResults = false;

 IGeoProcessorResult results = new GeoProcessorResultClass();
 IVariantArray parameters = new VarArrayClass();
 parameters.Add(tempFC);
 parameters.Add(outFC);
 results = gp.Execute("CopyFeatures_Management", parameters, null);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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