I like to run some scripts from mxd. Very often I am using Make Feature Layer tool to facilitate queries.
Tool help says: “Creates a feature layer from an input feature class or layer file. The layer that is created by the tool is temporary and will not persist after the session ends unless the layer is saved to disk or the map document is saved”.
Question:
How to remove newly created layer without closing mxd?
Note arcpy.mapping.RemoveLayer is not working on layer created that way or maybe I am doing something wrong here
arcpy.env.addOutputsToMap = Falseso that they never get added in the first place. Then when you terminate the ArcMap session the references should die too. – crmackey Feb 16 '16 at 03:08