It is through the Symbology class that you can gain access to a layer's renderer.
The typical workflow is to reference a feature layer's symbology, make changes, and then apply those changes back to the layer.
It is important to make sure that a layer supports a renderer and to know its type before trying to make updates to it. The built in hasattr function can be used for this purpose. Only the following feature layer renderers are currently supported in arcpy.mp: SimpleRenderer, GraduatedColorsRenderer, GraduatedSymbolsRenderer, and UniqueValueRenderer.
Gets the name of the renderer.
The updateRenderer method is used to change a layer's renderer.
The supported renderers are as follows:
The SimpleRenderer is the same as the single symbol renderer you see in the application. This name is used to be consistent with the .NET API.
The following script iterates through each feature layer and tests if its symbology supports the renderer property using the hasattr function. Next, if the renderer type is a SimpleRenderer, it will change it to a GraduatedColorsRenderer using the updateRenderer method and then sets its breakCount value to 6. Finally, it applies the symbology back to the layer before saving the results.
import arcpy, os, sys relpath = os.path.dirname(sys.argv) p = arcpy.mp.ArcGISProject(relpath + r'\\Symbol.aprx') m = p.listMaps('Map') for lyr in m.listLayers(): if lyr.isFeatureLayer: sym = lyr.symbology if hasattr(sym, 'renderer'): if sym.renderer.type == 'SimpleRenderer': sym.updateRenderer('GraduatedColorsRenderer') sym.renderer.breakCount = 6 lyr.symbology = sym p.saveACopy(relpath + r"\\SavedOutput.aprx")