<?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: Question regarding Symbology Renderers and .listMissingValues() in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/question-regarding-symbology-renderers-and/m-p/1207690#M65434</link>
    <description>&lt;P&gt;After opening a support ticket with Esri, this behavior has been replicated and is being logged as a defect (ENH-000151963). In the meantime, the best workaround would be to deploy the following:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;try:

    # Attempts to find the missing values and assign to list.
    list_missing_values = layer_symbology.renderer.listMissingValues()

except SystemError:

    # If no missing values, ignore the SystemError generated and assign the list to be empty.
    list_missing_values = []&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Aug 2022 19:06:45 GMT</pubDate>
    <dc:creator>David_Lindsey</dc:creator>
    <dc:date>2022-08-30T19:06:45Z</dc:date>
    <item>
      <title>Question regarding Symbology Renderers and .listMissingValues()</title>
      <link>https://community.esri.com/t5/python-questions/question-regarding-symbology-renderers-and/m-p/1206448#M65405</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I'm encountering an issue with my Python script (using the standard libraries packaged within Pro 3.0.0 and Pro 3.0.1 installs).&lt;BR /&gt;&lt;BR /&gt;My goal has been to update some symbology within my Pro project. To do this, I locate all values that are not part of our symbology rendering, and simply add them into the existing renderer group. Using the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/uniquevaluerenderer-class.htm" target="_blank" rel="noopener"&gt;.listMissingValues()&lt;/A&gt; functionality, I am able to locate these, add them with .addValues(), and this accomplishes the task successfully. Hooray!&amp;nbsp; However, the problem lies in scenarios where there are 0 missing values. If the script does not find any missing values, the tool fails and produces this error:&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;Traceback (most recent call last):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "C:\My\Python\Path\To\Script.py", line 27, in &amp;lt;module&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;list_missing_values = layer_symbology.renderer.listMissingValues()&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_renderer.py", line 41, in listMissingValues&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;self._arc_object.listMissingValues(*gp_fixargs((), True)))&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;SystemError: &amp;lt;built-in method listMissingValues of MappingSymbologyObject object at 0x00000172C4BAA9B0&amp;gt; returned NULL without setting an error&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;Is the .listMissingValues() method not designed to handle scenarios with 0 missing values, or am I missing something obvious? I assumed it would just spit out an empty list if it couldn't find any missing values, but that doesn't seem to be the case. I could band-aid this with a Try/Except to ignore SystemError messages for the .listMissingValues() step, but I would prefer not to do that.&lt;BR /&gt;&lt;BR /&gt;Anyway, thanks for any assistance!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Here is my script thus far (when there are 0 missing values, the error mentioned above occurs at Line 27):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

aprx = arcpy.mp.ArcGISProject("The\\Project\\Path\\Being\\Used.aprx")

for a_map in aprx.listMaps():

    if a_map.name != "Name of Map I am Needing":

        continue

    else:

        print("Map Name: " + a_map.name)

        for a_layer in a_map.listLayers():
            
            if a_layer.name != "Layer Name I am Needing":

                continue

            else:

                print("Layer Name: " + a_layer.name)

                layer_symbology = a_layer.symbology

                list_missing_values = layer_symbology.renderer.listMissingValues()

                if len(layer_symbology.renderer.groups) != 1:

                    print("Group count error, please check symbology groups.")

                else:

                    print("Symbology Group Header: " + str(layer_symbology.renderer.groups[0].heading))

                    if len(list_missing_values) == 0:

                        print("No missing values found.")

                    else:

                        for each_missing_value in list_missing_values:

                            print("Missing value count: " + str(len(each_missing_value.items)))

                            layer_symbology.renderer.addValues({layer_symbology.renderer.groups[0].heading: each_missing_value.items})

                            a_layer.symbology = layer_symbology

                        aprx.save()
                        print("Project saved.")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 20:03:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/question-regarding-symbology-renderers-and/m-p/1206448#M65405</guid>
      <dc:creator>David_Lindsey</dc:creator>
      <dc:date>2022-08-25T20:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: Question regarding Symbology Renderers and .listMissingValues()</title>
      <link>https://community.esri.com/t5/python-questions/question-regarding-symbology-renderers-and/m-p/1206488#M65406</link>
      <description>&lt;P&gt;You could try using a conditional to assign the value of the function if it is not Null or 0 if it is null.&lt;/P&gt;&lt;P&gt;EDIT to change the 0 to an empty list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;list_missing_values = layer_symbology.renderer.listMissingValues() if layer_symbology.renderer.listMissingValues() is not None else []&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can take this further and maybe get away with just using the method in the conditional:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;if layer_symbology.renderer.listMissingValues():
    for each_missing_value in layer_symbology.renderer.listMissingValues():
        do stuff
else:
    print("Nothing to do")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Depending where that error is triggered, try/except may be the way around it.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 19:22:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/question-regarding-symbology-renderers-and/m-p/1206488#M65406</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-25T19:22:44Z</dc:date>
    </item>
    <item>
      <title>Re: Question regarding Symbology Renderers and .listMissingValues()</title>
      <link>https://community.esri.com/t5/python-questions/question-regarding-symbology-renderers-and/m-p/1206494#M65407</link>
      <description>&lt;P&gt;Thanks for the idea, Jeff. I just tried it. Unfortunately it's failing with the same error message. It's like Python is getting hung up on the method itself (maybe on the backend somehow...?) and just failing outright. I'll keep digging.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 19:25:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/question-regarding-symbology-renderers-and/m-p/1206494#M65407</guid>
      <dc:creator>David_Lindsey</dc:creator>
      <dc:date>2022-08-25T19:25:05Z</dc:date>
    </item>
    <item>
      <title>Re: Question regarding Symbology Renderers and .listMissingValues()</title>
      <link>https://community.esri.com/t5/python-questions/question-regarding-symbology-renderers-and/m-p/1206503#M65408</link>
      <description>&lt;P&gt;rats, looks like a bug and try/except will probably be your best option until its fixed.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 20:01:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/question-regarding-symbology-renderers-and/m-p/1206503#M65408</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-25T20:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: Question regarding Symbology Renderers and .listMissingValues()</title>
      <link>https://community.esri.com/t5/python-questions/question-regarding-symbology-renderers-and/m-p/1207690#M65434</link>
      <description>&lt;P&gt;After opening a support ticket with Esri, this behavior has been replicated and is being logged as a defect (ENH-000151963). In the meantime, the best workaround would be to deploy the following:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;try:

    # Attempts to find the missing values and assign to list.
    list_missing_values = layer_symbology.renderer.listMissingValues()

except SystemError:

    # If no missing values, ignore the SystemError generated and assign the list to be empty.
    list_missing_values = []&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2022 19:06:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/question-regarding-symbology-renderers-and/m-p/1207690#M65434</guid>
      <dc:creator>David_Lindsey</dc:creator>
      <dc:date>2022-08-30T19:06:45Z</dc:date>
    </item>
  </channel>
</rss>

