<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Running a geoprocessing tool using background geoprocessing with custom tool in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/running-a-geoprocessing-tool-using-background/m-p/508509#M13668</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have one last update for this issue.&amp;nbsp; We have since tried running the code on another computer with ArcGIS 10.&amp;nbsp; The same issue occurs with this computer as well.&amp;nbsp; I have since revised my code to use the GPToolCommandHelper class in GeoprocessingUI.dll.&amp;nbsp; This invokes the same dialog that is used when you manually run a tool from ArcToolbox.&amp;nbsp; This works perfectly and is a good workaround to the issue.&amp;nbsp; See &lt;/SPAN&gt;&lt;A href="http://resources.esri.com/help/9.3/arcgisengine/dotnet/002c4e81-d8c4-4865-9e9b-374f5c174224.htm"&gt;http://resources.esri.com/help/9.3/arcgisengine/dotnet/002c4e81-d8c4-4865-9e9b-374f5c174224.htm&lt;/A&gt;&lt;SPAN&gt; for more information.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ken&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 19 Apr 2012 00:47:22 GMT</pubDate>
    <dc:creator>KennethBunzel</dc:creator>
    <dc:date>2012-04-19T00:47:22Z</dc:date>
    <item>
      <title>Running a geoprocessing tool using background geoprocessing with custom tool</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/running-a-geoprocessing-tool-using-background/m-p/508505#M13664</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to run a custom python script from an ArcMap toolbar and display messages created in the python script to the user in the ArcMap interface.&amp;nbsp; I am using ArcGIS 10 and the sample for this at &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/d/0001000001z2000000.htm"&gt;http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/d/0001000001z2000000.htm&lt;/A&gt;&lt;SPAN&gt;.&amp;nbsp; The sample works after I copied the sample data from my ArcGIS install folder to the same folder as the sample and modified the path to the data in the sample code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After I added my own custom toolbox/tool through _gp.AddToolbox(toolboxPath) and started the process with _gp.ExecuteAsync("TestScript", parameters), my custom tool also ran fine.&amp;nbsp; However, my problem is I can't figure out how to get it to display messages from the python script to the user.&amp;nbsp; The MessagesCreated event is not triggered from python code such as gp.AddMessage("test") or arcpy.AddMessage("test").&amp;nbsp; The sample only runs built in ArcToolbox tools such as clip and buffer with no associated python script that I can examine.&amp;nbsp; I'm wondering what needs to be done inside the python script to trigger the MessagesCreated event so I can display those message to the user?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ken&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Apr 2012 17:44:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/running-a-geoprocessing-tool-using-background/m-p/508505#M13664</guid>
      <dc:creator>KennethBunzel</dc:creator>
      <dc:date>2012-04-04T17:44:37Z</dc:date>
    </item>
    <item>
      <title>Re: Running a geoprocessing tool using background geoprocessing with custom tool</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/running-a-geoprocessing-tool-using-background/m-p/508506#M13665</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I write my messages to stdout in python and read those within the application.&amp;nbsp; Doesn't answer your question but another approach.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Writing_messages_in_script_tools"&gt;http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Writing_messages_in_script_tools&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Python&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;sys.stdout.write("false"") or print "false"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;sys.stdout.write(arcpy.GetMessages())&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In My C# Program&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;string result;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Process pProcess = new Process();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;result = pProcess.StandardOutput.ReadToEnd();&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Apr 2012 18:58:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/running-a-geoprocessing-tool-using-background/m-p/508506#M13665</guid>
      <dc:creator>JohnNelson3</dc:creator>
      <dc:date>2012-04-04T18:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: Running a geoprocessing tool using background geoprocessing with custom tool</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/running-a-geoprocessing-tool-using-background/m-p/508507#M13666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks John,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I might try your method if I can't get it to work using the method I'm using now.&amp;nbsp; I think I would have to call the script from a process.&amp;nbsp; What I am using now is the ESRI.ArcGIS.Geoprocessor.Geoprocessor class that calls the tool with gp.executeAsync.&amp;nbsp; I have also tried using ESRI.ArcGIS.Geoprocessing.GeoProcessor and calling the tool with gp.execute as in the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim GP As ESRI.ArcGIS.Geoprocessing.GeoProcessor = New ESRI.ArcGIS.Geoprocessing.GeoProcessor()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim geoProcessor As IGeoProcessor2 = DirectCast(GP, IGeoProcessor2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim gpEvents As gpEvents = New gpEvents(progressDialog)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; geoProcessor.RegisterGeoProcessorEvents(gpEvents)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim geoprocessorResult As IGeoProcessorResult = GP.Execute(toolName, parameters, Nothing)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MsgBox(geoprocessorResult.GetMessages(0))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; geoProcessor.UnRegisterGeoProcessorEvents(gpEvents)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the above code gpEvents is a class that implements IGeoProcessorEvents.&amp;nbsp; This class exposes an event called OnMessageAdded.&amp;nbsp; This event is supposed to get triggered when the python script has gp.AddMessage("message").&amp;nbsp; The PreToolExecute event in this class is properly triggered, but not the OnMessageAdded event.&amp;nbsp; 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.&amp;nbsp; But I need to run it from a form in ArcMap. Does anyone have any samples that use a custom python script?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ken&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Apr 2012 02:42:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/running-a-geoprocessing-tool-using-background/m-p/508507#M13666</guid>
      <dc:creator>KennethBunzel</dc:creator>
      <dc:date>2012-04-05T02:42:30Z</dc:date>
    </item>
    <item>
      <title>Re: Running a geoprocessing tool using background geoprocessing with custom tool</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/running-a-geoprocessing-tool-using-background/m-p/508508#M13667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have an update for this issue.&amp;nbsp; I have now tried running this on a computer with ArcGIS 9.3 with the same code.&amp;nbsp; There is no problem on this computer.&amp;nbsp; The OnMessageAdded event in ArcGIS is triggered by gp.AddMessage calls in the Python script.&amp;nbsp; So it works on a computer with ArcGIS 9.3 Windows Vista, but it does not work on a computer with ArcGIS 10 Windows 7.&amp;nbsp; I'm not sure if it is computer system related or if it is a difference between ArcGIS 9.3 and 10.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ken&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Apr 2012 16:30:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/running-a-geoprocessing-tool-using-background/m-p/508508#M13667</guid>
      <dc:creator>KennethBunzel</dc:creator>
      <dc:date>2012-04-05T16:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: Running a geoprocessing tool using background geoprocessing with custom tool</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/running-a-geoprocessing-tool-using-background/m-p/508509#M13668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have one last update for this issue.&amp;nbsp; We have since tried running the code on another computer with ArcGIS 10.&amp;nbsp; The same issue occurs with this computer as well.&amp;nbsp; I have since revised my code to use the GPToolCommandHelper class in GeoprocessingUI.dll.&amp;nbsp; This invokes the same dialog that is used when you manually run a tool from ArcToolbox.&amp;nbsp; This works perfectly and is a good workaround to the issue.&amp;nbsp; See &lt;/SPAN&gt;&lt;A href="http://resources.esri.com/help/9.3/arcgisengine/dotnet/002c4e81-d8c4-4865-9e9b-374f5c174224.htm"&gt;http://resources.esri.com/help/9.3/arcgisengine/dotnet/002c4e81-d8c4-4865-9e9b-374f5c174224.htm&lt;/A&gt;&lt;SPAN&gt; for more information.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ken&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Apr 2012 00:47:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/running-a-geoprocessing-tool-using-background/m-p/508509#M13668</guid>
      <dc:creator>KennethBunzel</dc:creator>
      <dc:date>2012-04-19T00:47:22Z</dc:date>
    </item>
  </channel>
</rss>

