AnsweredAssumed Answered

Changing Symbology Value Field for FC in TOC using Python

Question asked by tonalca6864 on May 15, 2018
Latest reply on May 16, 2018 by tonalca6864

Hi there

 

I've spent quite a while searching online and ArcGIS/ArcPy Help for a solution with no success, so I wonder if someone could think of a way around this issue:

 

I would like to change the symbology Value Field of a Feature Class within an MXD. I need first to set the symbology of the FC to "Match to symbols in a style" using a Value Field and then use Python to change the Value Field keeping the same symbology style. I know that ArcGIS does not support "Match to symbols in a style" symbology Type but I wonder if there is away around this.

It would be something like the script below but replacing the symbology Type with "something else". Hope I explained the issue clearly. Many thanks.

import arcpy

mxd = arcpy.mapping.MapDocument("CURRENT")

lyrlist = arcpy.mapping.ListLayers(mxd)

for lyr in lyrlist:

    if lyr.symbologyType == "UNIQUE_VALUES":

        lyr.symbology.valueField = "DESCRIPTION"
        lyr.symbology.addAllValues()

arcpy.RefreshActiveView()
arcpy.RefreshTOC()

del mxd

Outcomes