I have several mxds (located in C:\Project ) that have 250 layers each. All the layers as the same name- "plan" and they all in group layers like that (added picture for example):
I try to change all symbology layers of "plan" to the same symbology of layer "landuse":
All "plan" layers located one folder that divided to a lot of sub folders and sub-sub folders and their names (in the folders) are "kavim_kchulim". i try this code:
import arcpy,os,sys,string import arcpy.mapping from arcpy import env env.workspace = r"C:\Project" symbologyLayer = r"C:\Project\layers\landuse.lyr" for mxdname in arcpy.ListFiles("*.mxd"): print mxdname mxd = arcpy.mapping.MapDocument(r"C:\Project\\" + mxdname) dfList = arcpy.mapping.ListDataFrames(mxd, "*") for df in dfList: print df.name for lyr in arcpy.mapping.ListLayers(mxd, "", df): if lyr.name == "plan": arcpy.ApplySymbologyFromLayer_management("plan", symbologyLayer) print 'changed' mxd.save() del mxd
but get an error:
>>> Project.mxd Layers Traceback (most recent call last): File "C:\Users\yaron.KAYAMOT\Desktop\python.py", line 16, in <module> arcpy.ApplySymbologyFromLayer_management("plan", symbologyLayer) File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\management.py", line 6470, in ApplySymbologyFromLayer raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Input Layer: Dataset plan does not exist or is not supported Failed to execute (ApplySymbologyFromLayer).