Select to view content in your preferred language

How Can I fix this runtime error from addAllValues()?

470
1
01-13-2023 08:46 AM
rescobar
Regular Contributor

Hello, 

I am having trouble adding all values to layers symbology. If I use 'addAllValues()' by itself on one layer it works fine. However, when I create a list and do this en masse I get the following error:

 

 

 

 

 

Traceback (most recent call last):
  File "\\PDCCITRDSGIS02\Projects_3\PGE\00129_21_Kleinfelder_VegManagement\Tools\Scripts\Make_Figure2_experimental.py", line 77, in <module>
    hab_lyr.symbology.addAllValues()
  File "C:\Program Files (x86)\ArcGIS\Desktop10.8\ArcPy\arcpy\_mapping.py", line 1387, in addAllValues
    return convertArcObjectToPythonObject(self._arc_object.addAllValues(*gp_fixargs((), True)))
RuntimeError

 

 

 

 

 

 

 

 

 

 

An excerpt of my code is below. It is strange, because in my full code, I set a def query on hab_lyr with no problem. 

 

 

 

 

 

 

 

 

 

        for lyr in layers_list:
            print "Updating Work Area and Buffer Data Sources..."
            hab_lyr = arcpy.mapping.ListLayers(mxd, lyr)[0]
            if hab_lyr.symbologyType == "UNIQUE_VALUES":
                hab_lyr.symbology.addAllValues()

 

 

 

 

 

 

 

1 Reply
by Anonymous User
Not applicable

Add some print statements before the hab_lyr.symbology.addAllValues() so you know which layer is causing that error.  I tried it on a couple of my datasets and it didn't throw that error so you'll have to do some more debugging to narrow the issue down.

print 'changing: {}'.format(hab_lyr.name)
0 Kudos