How to list layers in memory in python idle

2609
4
11-14-2014 01:35 AM
NaimeCelik
Occasional Contributor

I am creating layers from shp file during my process on my python code.Using makefeaturelayer  tool puts lock file to the shp file and, if I do not delete that layer inside the code, I cannot erase that shp file due to lock.

 

My question is is there any way to extract names of created layers, so that I can erase them and prevent my shps having a lock file ?

Tags (2)
0 Kudos
4 Replies
JohannesBierer
Occasional Contributor III
0 Kudos
JohannesBierer
Occasional Contributor III
0 Kudos
NaimeCelik
Occasional Contributor

Hi Johannes,

Thanks for trying to help I checked those before, the difference is I am not working in a mxd document and  arcpy. mapping.ListLayers would not help, the thing is when I use  arcpy.MakeFeatureLayer_management tool, it will create layer without requiring the user to have any mxd and it will be created in memory, only solution seems like  just pick names of layers from code and use arcpy.Delete_management to erase them piece by piece. If you have another idea I would greatly appreciate that.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

I, too, would be interested if there was a way to see all of the layers and table views created with arcpy outside of ArcMap, but I haven't found a way yet.  Obviously within ArcObjects it is being done, but it doesn't seem to be exposed through arcpy.  I guess the logic is that if you are creating them in your code then you should have an idea what you have created and can delete them as well, i.e., track it yourself.  I wouldn't mind being wrong on this one.

0 Kudos