AnsweredAssumed Answered

Remove all layers except one

Question asked by DamianMilne on May 4, 2020
Latest reply on May 4, 2020 by DamianMilne

Hi, I'm making the transition from ArcMap to ArcGIS Pro so please forgive my ignorance...

At the start of my Arcpy script, I am trying to delete all of my layers in my layout except 'Coast'. When I run my script below it crashes ArcGIS Pro. Any advice graciously accepted.


aprx ="CURRENT")
mp = aprx.listMaps("Map")[0]

# Remove all layers except coast
keeplyr = mp.listLayers("Coast")
for rmlyr in mp.listLayers():
if rmlyr != keeplyr: