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
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.