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 ?

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Feb 11, 2016 at 7:49

1 Answer 1

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

answered Feb 11, 2016 at 8:21
3
  • isBroken Property is not working Commented Feb 11, 2016 at 8:39
  • is there any error or something? Commented Feb 11, 2016 at 8:43
  • apologies, i did something wrong in script, its working fine, thanks a lot. Commented Feb 11, 2016 at 8:57

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.