[GIS] Error 000732 – Input Layer “does not exist or is not supported” when using ‘ApplySymbologyFromLayer_management’

arcgis-10.2arcpyerror-000732layer-filesymbology

Using Arc 10.2

I am getting the following error message…

ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Input Layer: Dataset Q:\Data\Infrastructure\Infrastructure.gdb\LiftStations_Active does not
exist or is not supported
Failed to execute (ApplySymbologyFromLayer).

…when I run a script containing the following code snippet:

dest = arcpy.GetParameterAsText(1)
destWorkspace, destName = os.path.split(dest)
arcpy.FeatureClassToFeatureClass_conversion(source, destWorkspace, destName, "", mapping)
in_symbology_layer = r"Q:\Data\lyrfiles\LiftStations.lyr"
arcpy.ApplySymbologyFromLayer_management (dest, in_symbology_layer)

There are no problems with the first four lines of my snippet (all the parameters are legit and I'd rather spare you the entire or extraneous sections of my code). The error message says nothing about those lines and I've confirmed the "in_symbology_layer" exists (Q:\Data\lyrfiles\LiftStations.lyr).

I have double checked – the FC mentioned in the above error message does exist. In fact, since it comes directly from the tool's 2nd GetParameterAsText, the tool warns me that it "already exists" with the exclamation symbol beside the parameter field.

Why am I getting this error?

Further Thoughts

Am I not allowed to use "ApplySymbologyFromLayer_management" on a Feature Class? On a newly-created FC?

Does it have anything to do with the fact that since "dest" is an Output Parameter it gets deleted as soon as the script begins? (reference: "Why is “arcpy.GetParameterAsText” deleting Target Feature Class?")

Does it have anything to do with the fact that "dest" then gets recreated only two lines prior to 'ApplySymbologyFromLayer_management'?

Best Answer

Symbology applies to a layer, not to a feature class. From the help:

This tool applies the symbology from a layer to the Input Layer. It can be applied to feature, raster, network analysis, TIN, and geostatistical layer files or layers in the ArcMap table of contents.

You will need to make a feature layer within your code (the following is untested but should get you on the right track):

dest = arcpy.GetParameterAsText(1)
destWorkspace, destName = os.path.split(dest)
arcpy.FeatureClassToFeatureClass_conversion(source, destWorkspace, destName, "", mapping)
arcpy.MakeFeatureLayer_management (dest, "out_layer")
in_symbology_layer = r"Q:\Data\lyrfiles\LiftStations.lyr"
arcpy.ApplySymbologyFromLayer_management ("out_layer", in_symbology_layer)