Hello all. I have a script I am updating from ArcGIS Desktop (Python 2) to ArcGIS Pro (Python 3). As part of the older script I would cast a feature class as a feature layer via MakeFeatureLayer_management and then I would further cast that feature layer to a Layer object to get access to the layer's properties:
arcpy.MakeFeatureLayer_management(fc, "lyr")
lyr = arcpy.mapping.Layer("lyr")
It appears that the Pro version of arcpy doesn't actually have a layer object in the mapping (mp) module anymore. So, if I were to do something similar:
arcpy.MakeFeatureLayer_management(fc, "lyr")
lyr = arcpy.mp.Layer("lyr")
which returns:
AttributeError: module 'arcpy.mp' has no attribute 'Layer'
I also tried:
arcpy.MakeFeatureLayer_management(fc, "lyr")
lyr = arcpy.mp.LayerFile("lyr")
and threw the error:
ValueError: lyr
So, at the end of the day, I need to take a geodatabase feature class and somehow cast it as a layer in order to manipulate layer properties in arcpy for Pro. Any suggestion how I can do that. Points for avoiding saving the layer to disk.
Solved! Go to Solution.