import arcpy, os from arcpy import env arcpy.env.OverwriteOutput=True inputWS = r"C:/Temp/LAYERS" env.workspace=inputWS mxd=arcpy.mapping.MapDocument("CURRENT") df=arcpy.mapping.ListDataFrames(mxd,"Layers")[0] slayer=arcpy.ListFiles("*.lyr") lcount=len(slayer) print lcount for filelay in slayer: print filelay lyrFile=arcpy.mapping.Layer(inputWS+os.sep+filelay) arcpy.mapping.AddLayer(df,lyrFile) arcpy.RefreshTOC() arcpy.RefreshActiveView()
try using code tags for proper indentation
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.