emilharold

problem with arcpy.mapping.RemoveLayer

Discussion created by emilharold on Jan 18, 2014
Latest reply on Jan 20, 2014 by arekmatoszka
I'm trying to remove a layer from my map. this code:

    arcpy.AddMessage(str(arcpy.mapping.ListLayers (mxd, "", df)))
    arcpy.AddMessage(addstru)
    arcpy.mapping.RemoveLayer (df, addstru)
    arcpy.AddMessage(str(arcpy.mapping.ListLayers (mxd, "", df)))


gets me this result:

[<map layer u'StruxPts_v04'>, <map layer u'Land_Projects_Parcels_P6'>]
StruxPts_v04
[<map layer u'StruxPts_v04'>, <map layer u'Land_Projects_Parcels_P6'>]

As you can see, the layer 'StruxPts_v04' was not removed. When does this sort of thing occur?

Thanks!


EDIT: I'm thinking it has something to do with my searchcursor. addstru is searched, but I delete the cursor's variables prior to the code above.

Outcomes