1

i have created one python addin tool. which create some layers in Memory. at the end of the script it deletes the In memory layer. but such layer still remains in TOC with a broken link

layer with broken link

how can i remove such layer in python ?

5

There is property isBroken - Returns True if a layer's data source is broken.

   for layer in arcpy.mapping.ListLayers(mxd, "*", df):  
        if layer.isBroken:  
            arcpy.mapping.RemoveLayer(df, layer)  

Link to Esri help

  • isBroken Property is not working – Akhil Kumar Feb 11 '16 at 8:39
  • is there any error or something? – user7172 Feb 11 '16 at 8:43
  • apologies, i did something wrong in script, its working fine, thanks a lot. – Akhil Kumar Feb 11 '16 at 8:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.