AnsweredAssumed Answered

Help with sync.NewLayer

Question asked by JMossing on Oct 16, 2020

ArcPro 2.3.3. Automated project building using arcpy in a .pyt script. The legend.syncNewLayer = True line is not syncronizing or adding the layers into the legend element. The code is not producing any errors, seems to run, just nothing is getting added to the legend element. Not sure if I am doing something wrong of if there is some bug or other issue. I reviewed the LegendElement—ArcGIS Pro | Documentation my syntax seems to look correct:



lyt = aprx.listLayouts("Layout Name")[0]

m = aprx.listMaps("Analysis_Map")[0]

legend = lyt.listElements("LEGEND_ELEMENT", "Legend")[0]

legend.syncNewLayer = True




Then I iterate over all the layers and create them and add them to the TOC. I have also tried to place this line of code inline with creating the layers and nothing happens with the legend.

Any advise would be appreciated.