Error from Apply Symbology from Layer in Script Tool

266
0
06-23-2020 05:09 AM
NealBanerjee
Occasional Contributor

Hello,

I have a script tool loaded into a custom toolbox in ArcMap.  The script runs a bunch of sub-tools and creates a results layer.  I have created a .lyr file with desired symbology for the output results, and am using simple code in the script tool to load the resultant layer (location is user parameter).  See first code snippet below

If I used the 'default' settings in my tool where it writes to a specific database, everything works fine, but if I change to a different database, when I try to apply symbology to output layer, I get following error message.  It is suggeesting that layers do not match, but both are just simple polygons.  Again, it works without issue, if I write to the 'default' database, only when I change the location of database does it give error.

The really odd thing is it appears that it does apply the symbology, but has a broken source link.

Any ideas of what may be going on?

Thanks!

Neal 

---------------------BEGIN CODE SNIPPET TO LOAD LAYER AND APPLY SYMBOLOGY----------

outcurRskScrBldgsLyr = arcpy.MakeFeatureLayer_management(outcurRskScrBldgs,"zcurRiskScrBldgs")

curMXD=arcpymap.MapDocument("CURRENT")
df=arcpymap.ListDataFrames(curMXD)[0]
lyr=arcpymap.Layer("zcurRiskScrBldgs")
lyrfile=arcpymap.Layer(wksp+r"\_RARRSupportFiles\ArcGISLayerFiles\RARR_curRiskScrBldgs.lyr")
arcpymap.AddLayer(df,lyrfile,"TOP")
arcpy.ApplySymbologyFromLayer_management(lyr, lyrfile)

---------------------END CODE SNIPPER----------

----------- BEGIN ERROR MESSAGE ---------------

Traceback (most recent call last):
  File "C:\temp\RARR_OY1\_RARRSupportFiles\PythonScripts\RARR_CalcRskScr_Batch.py", line 171, in <module>
    arcpy.ApplySymbologyFromLayer_management(lyr, lyrfile)
  File "c:\program files (x86)\arcgis\desktop10.6\arcpy\arcpy\management.py", line 6951, in ApplySymbologyFromLayer
    raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000968: The symbol layer does not match the input layer
Failed to execute (ApplySymbologyFromLayer).

-------------------------------- END ERROR MESSAGE --------------------------

0 Kudos
0 Replies