Dear sir!
When I tried to create a .lyr file, The following error message come. I cant understand what's wrong with my script.
Please help me to solve it.
import arcpy
from arcpy import env
env.workspace = r"J:\Gampaha\51027202\CM51027202.gdb\CM51027202"
arcpy.MakeFeatureLayer_management("PCL_PG", "ASD")
arcpy.SaveToLayerFile_management("ASD", "AMD.lyr", "ABSOLUTE")
Traceback (most recent call last):
File "<pyshell#10>", line 1, in <module>
arcpy.SaveToLayerFile_management("ASD", "AMD.lyr", "ABSOLUTE")
File "C:\Program Files\ArcGIS\Desktop10.2\arcpy\arcpy\management.py", line 6640, in SaveToLayerFile
raise e
ExecuteError: ERROR 999999: Error executing function.
Failed to execute (SaveToLayerFile).
Thanks
Padmasiri
I think your issue is that you are trying to save the .lyr files to a geodatabase, someone correct me if I'm wrong, but I don't think you can save .lyr files to a gdb. You will need to save the layer files to a different workspace.
Dear Sir
Thanks to reply me.
I can understand what you said. In generally .lyr file cannot save within a geodatabase. it can be save in a folder.
Then I tried this way.
import arcpy
from arcpy import env
env.workspace = r"J:\Gampaha\51027202\CM51027202.gdb\CM51027202"
workspace = os.path.dirname(env.workspace)
arcpy.MakeFeatureLayer_management("PCL_PG", "ASD", "", workspace)
arcpy.SaveToLayerFile_management("ASD", "AMD.lyr", "ABSOLUTE")
Same error occurred.
Thanks
Padmasiri