ApplySymbologyFromLayer_management error: .LYR file made in 10.2 working with 10.1?

4632
3
02-28-2014 10:27 AM
JelmerOosthoek
New Contributor III
I'm working on a python add-in which includes a .LYR file with specific symbology. I use ApplySymbologyFromLayer_management to load a shapefile with this .LYR symbology in the ArcMap TOC. This works perfectly on my own testing PC with ArcGIS 10.2. But when I ask a test user to try the add-in on ArcGIS 10.1 the following error is returned:

ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000968: The symbol layer does not match the input layer
Failed to execute (ApplySymbologyFromLayer).


I can't easily debug this problem on the test user system and therefore, as a first step, I would like to find out if a .LYR file made in 10.2 should be backwards compatible with 10.1?

Thanks in advance!
Tags (2)
0 Kudos
3 Replies
XanderBakker
Esri Esteemed Contributor
Hi Jelmer,

The error "000968 : The symbol layer does not match the input layer" specifically states:

The symbol layer must be the same type as the input layer: feature layer, raster layer, network analysis layer, or TIN layer. For feature layers, the feature type and geometry type must also match. For network analysis layers, the solver type must match. For example, you cannot apply symbology from a service area layer to a route layer.

An ArcGIS 10.2 layerfile can be read by ArcGIS 10.1. You can see this if you choose to save a layerfile in 10.2 and click on the "save as layer type" list. All version are provided except 10.1 (meaning that the format is the same).

Check if the data types of the layers being used match.

Kind regards,

Xander
0 Kudos
JelmerOosthoek
New Contributor III
An ArcGIS 10.2 layerfile can be read by ArcGIS 10.1


Hi Xander,

That was what I was trying to find out. If this is true then something else must cause the error. The add-in works in 10.2 and there the data types match. The symbology layer is the .lyr file and the other layer I make on-the-fly using arcpy. I will need to wait until I can debug on 10.1.

Thanks for your reply,

Jelmer
0 Kudos
JelmerOosthoek
New Contributor III
I was able to solve the error. I changed:

layer = arcpy.mapping.Layer('C:\path\shapefile.shp')
symbologylayer = arcpy.mapping.Layer('C:\path\symbologylayer.lyr')
arcpy.ApplySymbologyFromLayer_management(layer, symbologylayer)


Into:

layer = arcpy.mapping.Layer('C:\path\shapefile.shp')
arcpy.ApplySymbologyFromLayer_management(layer, 'C:\path\symbologylayer.lyr')


The former code worked only on my PC, the latter code works on all PCs checked so far.
0 Kudos