lundi 23 mars 2015

SaveToLayerFile failed - "value is not a layer"


Tried doing a SaveToLayerFile on a layer in a workspace, but it confusingly says it's not a layer. I know it is a layer because the script can access lyr properties (e.g. name) and all of the symbology properties. The output folder is valid. Trying to run code in Python window.



import arcpy
lyr = arcpy.mapping.ListLayers(mxd, "Service*", df)[0]

print lyr.name # Returns name successfully

arcpy.SaveToLayerFile_management(lyr,"D:\Data\Workspace\Test.lyr")


Error below:


Runtime error Traceback (most recent call last): File "", line 38, in File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\management.py", line 6640, in SaveToLayerFile raise e ExecuteError: ERROR 000840: The value is not a Layer.


Any ideas? Cheers!





Aucun commentaire:

Enregistrer un commentaire