Set list of Item objects to the ItemGroup

231
2
05-06-2019 05:48 AM
nita14
by
Regular Contributor

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

0 Kudos
2 Replies
JoshuaBixby
MVP Esteemed Contributor

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.

0 Kudos
nita14
by
Regular Contributor

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

0 Kudos