Save To Layer File "Dataset does not exist or is not supported" error

Discussion created by calvingordon on Mar 8, 2012
Latest reply on Mar 8, 2012 by achapkowski-esristaff
I'm fairly new to python and arcpy. I'm picking it up quickly, but I've hit a wall on a script I'm working on. Here's the issue:

I'm trying to write a script to loop through each record in a feature class, export each record as a layer, save the layer as a layer file (so I can symbolize it), and then symbolize it.

I've got this working fine in my "test" mode (without using variables); however, when I add variables to act as parameters for the tools I'm using, I run into a problem. Specifically, it's the SaveToLayerFile_management() tool that's giving me this error:

...[previous code, see attachment for full code]...
arcpy.MakeFeatureLayer_management(srcFeature, inLayer, whereClause) #creates the layer based on crop type
arcpy.SaveToLayerFile_management("\"" + inLayer + "\"", "\"" + inLayer + "_layer\"") #should save the layer as croptype_layer. Syntax is fine as far as I can tell.
Runtime error <class 'arcgisscripting.ExecuteError'>: ERROR 000732: Input Layer: Dataset "Corn" does not exist or is not supported

"Corn" does exist! When I enter this into the python window...
arcpy.SaveToLayerFile_management("Corn", "Corn_layer") recognizes "Corn" and runs it fine.

Any help would be very much appreciated. This is driving me crazy!


p.s. I'm running this code in the Python Window in ArcMap 10, if that matters.