I have a python script that finds the feature class with the highest count for a field called 'SUM_USER_VisitCount' and then creates the symbology I specify. What I then want to do is save this feature class as a lyrx file, but the code I have for this seems to get skipped over. Can someone help me figure out what I'm doing wrong?
Here is a section of my code (let me know if you need to see the whole code):
### get key for dictionary item with the highest value
highest_count_layer = max(results_dict, key=results_dict.get)
for row in searchCursor:
Symbology_Layer = highest_count_layer
sym = Symbology_Layer.symbology
if hasattr(sym, 'renderer'):
if sym.renderer.type == 'SimpleRenderer':
sym.renderer.classificationField = 'SUM_USER_VisitCount'
sym.renderer.breakCount = 5
sym.renderer.colorRamp = p5.listColorRamps('Orange-Red (Continuous)')
### Remove decimal places from labels
if sym.renderer == "GraduatedColorsRenderer":
breaks = sym.renderer.classBreaks
for b in breaks:
b_int = b.label[0:-7]
b.label = b_int
### Thousands Separators in labels
def FindLabel (b):
Symbology_Layer.symbology = sym
### Where lyrx will be saved
arcpy.env.workspace = r"E:\arcGIS_Shared\Python\Symbology Layers"
### Set local variables
in_layer = Symbology_Layer
out_layer_file = r"E:\arcGIS_Shared\Python\Symbology Layers\SGF_CumulativeSymbology.lyrx"
arcpy.management.SaveToLayerFile(in_layer, out_layer_file, "ABSOLUTE")
print('Lyrx file saved')