I'm new to python, but I'm trying to apply the symbology from one layer to a group of others without manually importing each one. I could build a model using the ApplySymbologyFromLayer_management tool, but it does not work if there are features (e.g. polygons) missing in the layer; but I want these feature classes present across all layers because I am drawing them in. I was able to use the following python script to apply symbology to a single layer from another:
>>> import arcpy
>>> mxd = arcpy.mapping.MapDocument("Current")
>>> df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
>>> updateLayer = arcpy.mapping.ListLayers(mxd, "T33001700", df)[0]
>>> sourceLayer = arcpy.mapping.Layer(r"For Review\T23001510")[0]
Runtime error
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: 'Layer' object does not support indexing
>>> sourceLayer = arcpy.mapping.Layer(r"T23001510")
>>> arcpy.mapping.UpdateLayer(df, updateLayer, sourceLayer, True)
#But if I try to change the update layer to:
>>> updateLayer = arcpy.mapping.ListLayer(mxd, "In Progress", df) #where "In Progress" is the group of layers I want to change the symbology of
#then I get the error:
Runtime error
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\utils.py", line 182, in fn_
return fn(*args, **kw)
File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\mapping.py", line 1888, in UpdateLayer
assert isinstance(update_layer, Layer)
AssertionError