I need to update 200 MXD files by adding three layers with a specific symbology for each layer. I use ArcMap 10.8 All the layers are in the same folder. All the .mxd files are located in one folder which in diferent sub-folders and sub-sub-folders (not my choice) All the .lyr file are in one folder. All the folders are in different path. I am not familiar with Python environment or ArcPy but I am willing to try to write a script to automate the integration of the 3 layers with associated symbology in all the MXD.
I don't know if it's possible. I checked in French speaking forum with no luck so far. I found two scripts I am not sure on how to adapt them to my target. I tried the following as a total beginner...
import arcpy, os import arcpy.mapping as mapping for root, dirs, files in os.walk (r"path to the file containing all the MXD"): for f in files: if f.endswith(".mxd"): mxd = root + '\\' + f mxd_doc = mapping.MapDocument(mxd) df = mapping.ListDataFrames(mxd_doc) addLayer = arcpy.mapping.Layer(r"path_to_the_shapefile_1") arcpy.mapping.AddLayer(df ,addLayer ,"TOP") addLayer = arcpy.mapping.Layer(r"path_to_the_shapefile_2") arcpy.mapping.AddLayer(df ,addLayer ,"TOP") addLayer = arcpy.mapping.Layer(r"path_to_the_shapefile_3") arcpy.mapping.AddLayer(df ,addLayer ,"TOP") mapdoc.save() del mxd, addLayer, mapdoc
How do I apply the .lyr symbology to the layer in the MXD?