Quantcast
Channel: Question and Answer » arcpy
Viewing all articles
Browse latest Browse all 767

How to use list broken Data sources for layers saved in Windows not within an MXD

$
0
0

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:PROJECT2_USER_FOLDERSJOHN_SMITHLAYERS"

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_Container


import arcpy

my_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 lyr

At the moment I think I am passing my layers file that are saved here

folderPath = r”C:PROJECT2_USER_FOLDERSJOHN_SMITHLAYERS”

That are each listed as

C:PROJECT2_USER_FOLDERSJOHN_SMITHLAYERSa_layer.lyr

C:PROJECT2_USER_FOLDERSJOHN_SMITHLAYERSb_layer.lyr

Is this what should be passed into the

brokenlist = arcpy.mapping.ListBrokenDataSources('C:PROJECT2_USER_FOLDERSJOHN_SMITHLAYERSa_layer.lyr')

I am I missing something simple ?


Viewing all articles
Browse latest Browse all 767

Trending Articles