I'm writing an add-in for Arcmap and at the end of it I am left with multiple layers from buffers, joins, and selections. I am trying to delete these layers before the add-in finishes so to keep the number of layers in TOC to a minimum. Below is the piece of code I am using to delete the layers, and the error it rasies.
f = ['Select_1', 'Join_1', 'Buff_1'] for x in f: arcpy.Delete_management(x)
Runtime error Traceback (most recent call last): File "", line 2, in File "c:\program files (x86)\arcgis\desktop10.7\arcpy\arcpy\management.py", line 4359, in Delete raise e ExecuteError: ERROR 000622: Failed to execute (Delete). Parameters are not valid. ERROR 000628: Cannot set input into parameter in_data.
RemoveLayerfunction: desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-mapping/… Or specify that intermediate layers should not be added to the TOC. Depending upon your workflow, you may be able to use
in_memoryworkspace to manage intermediate data.
Delete_management()is for deleting data (permanently), not remove a layer from your map