I have seen a few question related to listing broken data sources of layers within an MXD MXD list broken links See Link .
I am interested in layers that are not within an MXD. That are sitting within a windows file directory
It seems the syntax is the same , maybe I am passing a file string that is not in the correct format my code is as follows
folderPath = r"C:\PROJECT\02_USER_FOLDERS\JOHN_SMITH\LAYERS"def Get_Layer_files(Folderpath): import arcpy,os ws = arcpy.env.workspace = folderPath arcpy.env.overwriteOutput = True Layer_Container =[] Layer_List = arcpy.ListFiles("*.lyr") for layer in Layer_List: Full_Name = folderPath + "\\" + layer Layer_Container.append(Full_Name) return Layer_Containerimport arcpymy_list = Get_Layer_files(folderPath)for file in my_list: lyrfile = arcpy.mapping.Layer(file) lyrlist = arcpy.mapping.ListLayers(lyrfile) for lyr in lyrlist: brokenlist = arcpy.mapping.ListBrokenDataSources(file) for lyr in brokenlist: print lyrAt the moment I think I am passing my layers file that are saved here
folderPath = r"C:\PROJECT\02_USER_FOLDERS\JOHN_SMITH\LAYERS"
That are each listed as
C:\PROJECT\02_USER_FOLDERS\JOHN_SMITH\LAYERS\a_layer.lyr
C:\PROJECT\02_USER_FOLDERS\JOHN_SMITH\LAYERS\b_layer.lyr
Is this what should be passed into the
brokenlist = arcpy.mapping.ListBrokenDataSources('C:\PROJECT\02_USER_FOLDERS\JOHN_SMITH\LAYERS\a_layer.lyr')I am I missing something simple ?
أكثر...
I am interested in layers that are not within an MXD. That are sitting within a windows file directory
It seems the syntax is the same , maybe I am passing a file string that is not in the correct format my code is as follows
folderPath = r"C:\PROJECT\02_USER_FOLDERS\JOHN_SMITH\LAYERS"def Get_Layer_files(Folderpath): import arcpy,os ws = arcpy.env.workspace = folderPath arcpy.env.overwriteOutput = True Layer_Container =[] Layer_List = arcpy.ListFiles("*.lyr") for layer in Layer_List: Full_Name = folderPath + "\\" + layer Layer_Container.append(Full_Name) return Layer_Containerimport arcpymy_list = Get_Layer_files(folderPath)for file in my_list: lyrfile = arcpy.mapping.Layer(file) lyrlist = arcpy.mapping.ListLayers(lyrfile) for lyr in lyrlist: brokenlist = arcpy.mapping.ListBrokenDataSources(file) for lyr in brokenlist: print lyrAt the moment I think I am passing my layers file that are saved here
folderPath = r"C:\PROJECT\02_USER_FOLDERS\JOHN_SMITH\LAYERS"
That are each listed as
C:\PROJECT\02_USER_FOLDERS\JOHN_SMITH\LAYERS\a_layer.lyr
C:\PROJECT\02_USER_FOLDERS\JOHN_SMITH\LAYERS\b_layer.lyr
Is this what should be passed into the
brokenlist = arcpy.mapping.ListBrokenDataSources('C:\PROJECT\02_USER_FOLDERS\JOHN_SMITH\LAYERS\a_layer.lyr')I am I missing something simple ?
أكثر...