Hmm, works for me.
Save this script as a Python file in your project folder and run it:
import arcpy
aprx_name = "Admin.aprx"
map_name = "Test"
lyr_name = "New Group Layer"
aprx = arcpy.mp.ArcGISProject(aprx_name)
m = aprx.listMaps(map_name)[0]
lyr = m.listLayers(lyr_name)[0]
arcpy.management.SaveToLayerFile(lyr, "test1.lyrx")
lyr.saveACopy("test2.lyrx")
Hi Johannes,
I tried your code. "test1.lyrx" is invalid. While "test2.lyrx" is valid (no problem to open or load into other project).
Is it the same as you?
Thanks,
Zhongyu
Is it the same as you?
Nope, I can open both layers without problems. I don't know what the cause for your problem could be, but you could always just use the second method...