I've created a list of the layers in the map and I'm trying to then use that list to match symbology to a style. Is it possible? When I try I get an error.
import arcpy
import random
from itertools import groupby
from collections import defaultdict
aprx = arcpy.mp.ArcGISProject("CURRENT")
act_map = aprx.activeMap
map1 = aprx.listMaps("Map1")
layer = act_map.listLayers()
lyr_list = []
for position in range(0, len(layer)):
lyr_name = layer[position].name
lyr_list.append(lyr_name)
arcpy.management.MatchLayerSymbologyToAStyle(lyr_list, "$feature.Type", r"\\Path\ArcGIS_Styles.stylx")
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 10200, in MatchLayerSymbologyToAStyle
raise e
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 10197, in MatchLayerSymbologyToAStyle
retval = convertArcObjectToPythonObject(gp.MatchLayerSymbologyToAStyle_management(*gp_fixargs((in_layer, match_values, in_style), True)))
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
RuntimeError: Object: Error in executing tool