AnsweredAssumed Answered

Error trying to save layer from MXD to lyrx.

Question asked by scottwi_NYCDDC on Oct 9, 2019
Latest reply on Oct 11, 2019 by scottwi_NYCDDC

I am trying to load a layer from an mxd and back up the layer using ArcGIS Pro and Python.

 

aprx.importDocument(current_document_name)
mlist = aprx.listMaps()
infra_layers = mlist[0].listLayers()
new_file_name = backup_geodatabase_path + 'ActiveInfraProjects.lyrx'
arcpy.SaveToLayerFile_management(infra_layers[0].name, new_file_name, 'ABSOLUTE')
#I get the following error:

ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Input Layer: Dataset active_infrastructure_projects does not exist or is not supported
Failed to execute (SaveToLayerFile).

#It says it doesn't exist but I was able to get the name from the file (infra_layers[0]) so it must exist.
#Why is it not supported?

Outcomes