Dear All,
ArcPy and ArcGIS Pro 2.3.2
Was anybody here successfull in setting a list of sorted Item objects based on features count to the ItemGroup (Unique Value Renderer)? Everytime I try it, I receive an error saying that such attribute cannot be set or ArcGIS Pro crashes unexpectedly. According to the docs, the list if items can be changed. ItemGroup—ArcPy | ArcGIS Desktop. Cannot?
I thought something like the snippet below would do the job, but it doesn't:
sym.renderer.groups
[0].items = new_list_of_sorted_Item_objects
Any hints?
Thanks!
Adam
It helps to provide more code. For example, where/how do you get the list of Item objects that you are sorting? How are you sorting the list?
That all said, I was able to crash Pro while tinkering with setting the unique value renderer, so there is a defect because the application should never crash completely. I suggest you open a case with Esri Support.
Dear Joshua,
Thank you for your support. Here is the code I tried to run:
p = arcpy.mp.ArcGISProject('CURRENT')
m = p.listMaps('Map1')[0]
l = m.listLayers('Lines*')[0]
sym = l.symbology
sym
new_list = []
new_list.append(sym.renderer.groups[0].items[1])
new_list.append(sym.renderer.groups[0].items[2])
new_list.append(sym.renderer.groups[0].items[0])
new_list.append(sym.renderer.groups[0].items[3])
new_listsym.renderer.groups[0].items
sym.renderer.groups[0].items = new_list
and the screenshot with the error:
Well, most probably in the end I will have to direct to Esri Support, but maybe somebody in the community already came across this issue and found a workaround. Keeping my fingers crossed.
BR
Adam
Has there been an update on this? I am also trying to reorder how the symbols appear in the legends and got an error setting the items property like in the first post. I could update each item's symbol and label but not the values so can't do it that way.
I am looking for a way to re-order symbology associated with a layer with ArcPy. If I can't do this by modifying uniqueValuesRender is there another way?
The goal is to allow users to pick the order by which symbols appear in the legend. This needs to be done in ArcPy.