lucamoiana

Remove broken links from a list

Discussion created by lucamoiana on Aug 21, 2012
Latest reply on Aug 21, 2012 by lucamoiana
Hello,
I create a list of feature in an MXD files, now I'd like to remove the features with broken links.
What I did is create two list:
1 features in MXD
2 features in MXD with broken links
Now I'd like to subtract...but ain't working.
Here is a code sample:

##############################
# LIST ALL SHP IN MXD
list = []
df_list = arcpy.mapping.ListDataFrames (mxd)
for df in df_list: 
    for fc in arcpy.mapping.ListLayers (mxd, "", df):
  if (fc.supports("DATASOURCE")) and (fc.dataSource.endswith(".shp")):
                    list.append(fc)
print("List created")

#############################
# REMOVE BROKEN LINKS FROM LIST
brokenList = arcpy.mapping.ListBrokenDataSources(mxd)
for broken in brokenList:
    list.remove(broken)
    print ("Broken data removed from list")

Outcomes