Thanks John,
I might try your method if I can't get it to work using the method I'm using now. I think I would have to call the script from a process. What I am using now is the ESRI.ArcGIS.Geoprocessor.Geoprocessor class that calls the tool with gp.executeAsync. I have also tried using ESRI.ArcGIS.Geoprocessing.GeoProcessor and calling the tool with gp.execute as in the following:
Dim GP As ESRI.ArcGIS.Geoprocessing.GeoProcessor = New ESRI.ArcGIS.Geoprocessing.GeoProcessor()
Dim geoProcessor As IGeoProcessor2 = DirectCast(GP, IGeoProcessor2)
Dim gpEvents As gpEvents = New gpEvents(progressDialog)
geoProcessor.RegisterGeoProcessorEvents(gpEvents)
Dim geoprocessorResult As IGeoProcessorResult = GP.Execute(toolName, parameters, Nothing)
MsgBox(geoprocessorResult.GetMessages(0))
geoProcessor.UnRegisterGeoProcessorEvents(gpEvents)
In the above code gpEvents is a class that implements IGeoProcessorEvents. This class exposes an event called OnMessageAdded. This event is supposed to get triggered when the python script has gp.AddMessage("message"). The PreToolExecute event in this class is properly triggered, but not the OnMessageAdded event. Curiously, if I remove the geoProcessor.UnRegisterGeoProcessorEvents(gpEvents) code above, and run the same tool from within ArcToolbox (after first calling the above code from my form), the OnMessageAdded event does get triggered. But I need to run it from a form in ArcMap. Does anyone have any samples that use a custom python script?
Ken