- I'm trying to loop through all my layers looking for layer named
- If the layer exists then remove the layer from the mxd
- Running from Stand-Alone script (ie. NOT within Arcmap)
"CADAnnotation"Data Type is a CAD Annotation Feature Class
"CADAnnotation"is NOT in a geodatabase, it's created from a AutoCAD .dwg
"CADAnnotation"is within a Group Layer named
- If the group layer
"ACAD"can be deleted that also removes
"CADAnnotation"that would be great.
Code thus far:
for item in mxds: print (item) mxd = arcpy.mapping.MapDocument(item) df=arcpy.mapping.ListDataFrames(mxd,"Project Area") for lyr in arcpy.mapping.ListLayers(mxd, "*",df): if lyr.name == "CADAnnotation": print(lyr.dataSource) arcpy.Delete_management("CADAnnotation") print("Layer Deleted") else: pass
Notes on Code:
- I can find the layer no problem
- the line
arcpy.Delete_management("CADAnnotation")does not work throws an error.
- How to I remove