It is possible to save custom symbology to a style file within the Format Symbol pane, but is there an ArcPy command to save symbology to a style file?

I have rich symbology which needs to be transferred to another project and would like to loop over all feature layers (each feature layer has a unique value symbology) which are in a Map, and save each symbol to style.

Below is example symbology of just one feature layer.

Symbology of just one FL

closed as off-topic by PolyGeo Oct 25 '18 at 21:17

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "When seeking help to debug/write/improve code always provide the desired behavior, a specific problem/error and the shortest code (as formatted text, not pictures) needed to reproduce it in the question body. Providing a clear problem statement and a code attempt helps others to help you." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.


You could get and loop through a list of the layers in your table of contents, and then use the SaveToLayerFile_management (in_layer, out_layer, {is_relative_path}, {version}) tool to save a layer file of each listed layer.

  1. Get a list of layers in the table of contents.
  2. Loop/iterate through the list of layers.
  3. Run SaveToLayerFile_management on each layer in the loop.

Here is a working/tested code sample...

import arcpy
aprx = arcpy.mp.ArcGISProject(r'C:\Users\your_name\Documents\ArcGIS\Projects\Proj_123\Proj_123.aprx')
m = aprx.listMaps("Map1")[0]
for lyr in m.listLayers():
    out_dir = r'C:\\Users\\your_name\\Documents\\ArcGIS\\Projects\\Proj_123\\Layers\\'
    out_suffix = r'.lyrx'
    out_layer = out_dir + str(lyr) + out_suffix
    arcpy.SaveToLayerFile_management (lyr, out_layer, "RELATIVE") 
del aprx

Not the answer you're looking for? Browse other questions tagged or ask your own question.