Feature Layer no longer accesible after MakeFeatureLayer_management

Feature Layer no longer accesible after MakeFeatureLayer_management

I am creating a new layer out of an old one withMakeFeatureLayer_managementlike this:

arcpy.MakeFeatureLayer_management("layername", "newlayername", "DEPTH = 1200")

This works for the first time but if I want to execute the function on the same layer again (with a newout_layerand a differentwhere clause) like this:

arcpy.MakeFeatureLayer_management("layername", "secondlayername", "DEPTH = 1400")

I get

Runtime error Traceback (most recent call last):
File "", line 1, in
File "c:program files (x86)", line 5774, in MakeFeatureLayer
raise e ExecuteError: ERROR 000622: Failed to execute (Make Feature Layer). Parameters are not valid. ERROR 000628: Cannot set input into parameter in_features.

Also the auto completion forin_featuresno longer shows the used layer.

What can I do to fix this?

Based on the edits to your original question, try something like this:

import arcpy input = "featureclass or shapefile" arcpy.MakeFeatureLayer_management(input, "newlayer", "query") arcpy.MakeFeatureLayer_management(input, "newlayer2", "query")

Make the input to the MakeFeatureLayer management tool the dataset rather than a layer created from the dataset.