I have some scripting where the goal has been to create data and spatializes them from tables through an FME workbench saved as a data interop tool and saved in a FGDB, which then a script is ran to add them into the map frame, and changes the names of the feature classes. Those all work, however when I get to the symbology script I have, it runs and works just fine in the window, but does not work in a model.

import arcpy

# Set the map name where you want to symbolize the feature class
map_name = "Map"  # Change this to match your map name

# Get the current project
aprx = arcpy.mp.ArcGISProject("CURRENT")

# Get the map frame
map_frame = aprx.listMaps(map_name)[0]

# Dictionary to map layer name to symbology layer file (for one layer)
layer_to_symbology_mapping = {
    "Layer_Example": r"D:\Layer_Example.lyrx"

# Loop through the layers in the map frame and apply symbology
for lyr in map_frame.listLayers():
    # Check if the layer name has a mapping in the dictionary
    if lyr.name in layer_to_symbology_mapping:
        symbology_layer = layer_to_symbology_mapping[lyr.name]
        # Apply symbology from the layer file
        arcpy.management.ApplySymbologyFromLayer(lyr, symbology_layer)
        print(f"Symbology applied to {lyr.name} using {symbology_layer}")

# Save the project

I am a bit stumped, when it runs in ModelBuilder, it doesn't throw an error, it will give a lock on the layer in the drawing order, but nothing happens, but works like a charm in the Python window. Any ideas on what could be happening?

  • What do you mean "in a model"? Please explain how you are running this script "in a model". Aug 24, 2023 at 3:53
  • It is 4 year old problem. Apply symbology is not working from script either.
    – FelixIP
    Aug 24, 2023 at 9:54

1 Answer 1


Yes, it is. ApplySymbologyFromLayer is not working from script. This is workflow with layer saved as .lyr or .lyrx file:

L = m.addDataFromPath(ps)
sym = L.symbology
lyr = m.listLayers(inBuildings)[0]
lyr.symbology = sym

where m is map, ps is path to .lyr file and lyr is the one to receive this symbology. Works even with 'broken' .lyr

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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