<?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: arcpy.GetMessages returns empty [BUG] in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-getmessages-returns-empty-bug/m-p/385278#M30384</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;What then does the documentation refer to ?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You are completely right. I does not seem to do what is described in the help. Even the slightly change sample script does not return what one should expect based on the description.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
fc = r'C:\Project\_Forums\ZonStatPol\test.gdb\Intersect'
feature_count = int(arcpy.GetCount_management(fc).getOutput(0))

if feature_count == 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError("{0} has no features.".format(fc))
else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("{0} has {1} features.".format(fc, feature_count))

print arcpy.GetMessages()&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Results in:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-family:courier new;"&gt;Executing: GetCount C:\Project\_Forums\ZonStatPol\test.gdb\Intersect&lt;BR /&gt;Start Time: Tue Feb 25 15:46:45 2014&lt;BR /&gt;Row Count = 10&lt;BR /&gt;Succeeded at Tue Feb 25 15:46:45 2014 (Elapsed Time: 0,19 seconds)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;... which is the output of the geoprocessing tool &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;GetCount_management&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Said, but true (or I simply don't get it).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Xander&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 17:42:42 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2021-12-11T17:42:42Z</dc:date>
    <item>
      <title>arcpy.GetMessages returns empty [BUG]</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-getmessages-returns-empty-bug/m-p/385275#M30381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am trying to access the messages that were logged throughout a script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
arcpy.AddMessage("Something...")
message = arcpy.GetMessages()
print message&amp;nbsp; # always empty
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The above is always empty.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;According to the documentation [&lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/AddMessage/018v00000007000000/]" rel="nofollow noopener noreferrer" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#/AddMessage/018v00000007000000/]&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Creates a geoprocessing informative message (Severity=0) that can be accessed with any of the GetMessages functions.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What am I missing here?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm starting to think this is either a bug or something not documented.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:42:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-getmessages-returns-empty-bug/m-p/385275#M30381</guid>
      <dc:creator>Matrix_Solutions_Inc_Geomatics</dc:creator>
      <dc:date>2021-12-11T17:42:36Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.GetMessages returns empty [BUG]</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-getmessages-returns-empty-bug/m-p/385276#M30382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Tony,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;arcpy.AddMessage()&lt;/SPAN&gt;&lt;SPAN&gt; will add a message that is visible if you run your script as a tool from a toolbox. The &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;arcpy.GetMessages()&lt;/SPAN&gt;&lt;SPAN&gt; will return the messages from a geoprocessing tool used. In your example script you don't run any tool, so no message is returned.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I create a simple script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
arcpy.AddMessage("Something...")
arcpy.AddMessage("Blah...")

cnt = 0
for message in arcpy.GetMessages():
&amp;nbsp;&amp;nbsp;&amp;nbsp; cnt += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Message {0} is '{1}'".format(cnt, message))

arcpy.AddMessage("arcpy.GetMessageCount() results in: {0}".format(arcpy.GetMessageCount()))&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The output in the tool window will be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-family:courier new;"&gt;Executing: Script&lt;BR /&gt;Start Time: Tue Feb 25 08:20:02 2014&lt;BR /&gt;Running script Script...&lt;BR /&gt;&lt;STRONG&gt;Something...&lt;BR /&gt;Blah..&lt;/STRONG&gt;.&lt;BR /&gt;&lt;STRONG&gt;arcpy.GetMessageCount() results in: &lt;SPAN style="color:#ff0000;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;BR /&gt;Completed script Script...&lt;BR /&gt;Succeeded at Tue Feb 25 08:20:02 2014 (Elapsed Time: 0,00 seconds)&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Xander&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:42:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-getmessages-returns-empty-bug/m-p/385276#M30382</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T17:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.GetMessages returns empty [BUG]</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-getmessages-returns-empty-bug/m-p/385277#M30383</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;What then does the documentation refer to ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/AddMessage/018v00000007000000/]"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#/AddMessage/018v00000007000000/]&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;AddMessage (arcpy)&lt;BR /&gt;Summary&lt;BR /&gt;Creates a geoprocessing informative message (Severity=0) that can be accessed with any of the GetMessages functions.&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 12:29:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-getmessages-returns-empty-bug/m-p/385277#M30383</guid>
      <dc:creator>Matrix_Solutions_Inc_Geomatics</dc:creator>
      <dc:date>2014-02-25T12:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.GetMessages returns empty [BUG]</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-getmessages-returns-empty-bug/m-p/385278#M30384</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;What then does the documentation refer to ?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You are completely right. I does not seem to do what is described in the help. Even the slightly change sample script does not return what one should expect based on the description.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
fc = r'C:\Project\_Forums\ZonStatPol\test.gdb\Intersect'
feature_count = int(arcpy.GetCount_management(fc).getOutput(0))

if feature_count == 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError("{0} has no features.".format(fc))
else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("{0} has {1} features.".format(fc, feature_count))

print arcpy.GetMessages()&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Results in:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-family:courier new;"&gt;Executing: GetCount C:\Project\_Forums\ZonStatPol\test.gdb\Intersect&lt;BR /&gt;Start Time: Tue Feb 25 15:46:45 2014&lt;BR /&gt;Row Count = 10&lt;BR /&gt;Succeeded at Tue Feb 25 15:46:45 2014 (Elapsed Time: 0,19 seconds)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;... which is the output of the geoprocessing tool &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;GetCount_management&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Said, but true (or I simply don't get it).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Xander&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:42:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-getmessages-returns-empty-bug/m-p/385278#M30384</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T17:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.GetMessages returns empty [BUG]</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-getmessages-returns-empty-bug/m-p/385279#M30385</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the quick reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Would you happen to know if the messages get written somewhere else in the interpreter? or rather, the ultimate place that they trickle down to?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; I tried redirecting sys.stdout / sys.stderr but it seem arcpy.AddMessage doesn't seem to write to there either. However, there must be a standard Python object that receives the messages because my IDE console always displays them.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 13:02:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-getmessages-returns-empty-bug/m-p/385279#M30385</guid>
      <dc:creator>Matrix_Solutions_Inc_Geomatics</dc:creator>
      <dc:date>2014-02-25T13:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.GetMessages returns empty [BUG]</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-getmessages-returns-empty-bug/m-p/385280#M30386</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Tony,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can't find where this information is stored. Maybe some implementation of the logging module, although most of the functionality goes through ArcObjects...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I guess it's not so hard to implement an alternative, but if you want to keep using the messaging of arcpy, it might be wise to contact Esri support and report the bug. Maybe in a future release they fix the bug, or change the help text &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Xander&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 14:01:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-getmessages-returns-empty-bug/m-p/385280#M30386</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2014-02-25T14:01:50Z</dc:date>
    </item>
  </channel>
</rss>

