0

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'?

  • 1
    Are you sure about the second line of your code snippet? I think that first backslash needs to be doubled and the r removed. Or alternatively, undouble all your double slashes and leave the r in place. – PolyGeo Jul 10 '18 at 0:42
  • 1
    What is the value of destWorkspace? If it doesn't have a terminating separator there could be a problem there.. best to use os.path.join(destWorkspace,destName) rather than destWorkspace+destName. But, yes, apply symbology from layer only works on layers not feature classes or rasters. You can use MakeFeautreLayer to create a layer from your feature class. – Michael Stimson Jul 10 '18 at 0:48
  • The values of "destWorkspace" and "destName" were originally split apart from "dest" because FeatureClasstoFeatureClass_conversion requires them as two separate parameters. I've just put "dest" in as a parameter for "ApplySymbology" now. It is derived straight from the tool via "GetParameterAsText" and when I print its value it reads "Q:\Data\Infrastructure\Infrastructure.gdb\Liftstations_Active". – Waterman Jul 10 '18 at 21:19
1

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)
0

You have too many backslashes in your path to your layer file. r means raw string, so no need for \\ when you use r

in_symbology_layer = r"Q:\GW\EC1210WQAEH_QESEA\CSSP_ATL\Data\lyrfiles\LiftStations_NB_Active.lyr"

destWorkspace+destName looks suspicious. Try:

import os
arcpy.ApplySymbologyFromLayer_management (os.path.join (destWorkspace, destName), in_symbology_layer)
  • The problem still exists in case you have any further ideas? – Waterman Jul 16 '18 at 23:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.