Select to view content in your preferred language

Unique Value Renderer Arcpy reading wrong field

613
1
08-22-2021 03:39 PM
anamanvil
New Contributor II
Hi All,
 
For some reason my code which loop through my Unique Value Renderer group items started to fail and now it is not reading the field I give (Symbology) but the first field within the layer attribute table (similarly to when you set UniqueValueRenderer manually where the first field is the default one)
 
Is there anything wrong in the below, I have been investigating this for days ... 
 
sym = layer.symbology
sym.updateRenderer("UniqueValueRenderer")
if sym.renderer.type == "UniqueValueRenderer":
    sym.renderer.fields = ["Symbology"]
    for grp in sym.renderer.groups:
        for item in grp.items:
            arcpy.AddMessage(item.label)
 
Thanks,
Ana
0 Kudos
1 Reply
JeffBarrette
Esri Regular Contributor

Hello Ana,

I could not reproduce the issue using your same code.  I was able to successfully run your code.  There where some weird embedded tabs but that was probably just a paste from this forum page.  Make sure you have the field name correct.  It defaults to the first field if the name you specify is not valid.  If this used to work and no longer does it might be data specific.  It would be best to open an issue with Esri support to get help developing a reproducible case that I can investigate.

Jeff - Layout and arcpy.mp teams

0 Kudos