Error setting field for UniqueValueRenderer

2823
10
05-09-2023 06:20 AM
TorbjørnDalløkken2
Frequent Contributor

Hi. 

I'm trying to change the symbology of one of my layers in a python script. I've found the given layer 

 

# Get layer "Vegteig" from active map
aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.activeMap
fl_vegteig = m.listLayers("Vegteiger")[0]

 

Then I'm trying to define a new UniqueValueRenderer for the layer:

 

symb = fl_vegteig.symbology
symb.updateRenderer("UniqueValueRenderer")
symb.renderer.fields = ['TILKNYTTET']

 

 When I try to run this, I get this error:

The attribute 'fields' is not supported on this instance of UniqueValueRenderer

Does anyone know what might be wrong? I'm using almost the same code in another script (same toolbox), which works perfectly.

10 Replies
AlanTonkin1
New Contributor

Just came across this and have found it super useful. I have successfully used the script to load images as symbols for around 400 unique class values. What I have searched for and not found, is how to set the Quality attribute to "Picture" rather than the "Draft" that it defaults to.

I added in another line between where the Size and the URL are set as per below:

"quality": 'Picture',

 I also tried 'Picture Quality' and neither option had any affect.

There are too many to go and set this manually for 400 unique values. Any ideas?

0 Kudos