Bug ID Number |
BUG-000125587 |
Submitted | September 26, 2019 |
Last Modified | June 5, 2024 |
Applies to | ArcGIS Pro |
Version found | 2.4.1 |
Operating System | Windows OS |
Operating System Version | 10.0 |
Status | As Designed
After review by the development team, it has been determined that this behavior is as designed. See the Additional Information section for details.
|
Additional Information
The MakeFeatureLayer_management tool does not return a layer object but instead a result object. Extract the layer from the result using the appropriate index. In this case, it is [0].
The object at index 0 in the result object is the layer to add. Use the following code:
temp = arcpy.MakeFeatureLayer_management(r"C:\Temp\GreatLakes\GreatLakes.gdb\GreatLakes", "TestOutput")[0]
p = arcpy.mp.ArcGISProject('current')
m = p.listMaps('Map')[0]
m.addLayer(temp)
Workaround
The object at index 0 in the result object is the layer to add Use the following code:
temp = arcpy.MakeFeatureLayer_management(r"C:\Temp\GreatLakes\GreatLakes.gdb\GreatLakes", "TestOutput")[0]
p = arcpy.mp.ArcGISProject('current')
m = p.listMaps('Map')[0]
m.addLayer(temp)
Steps to Reproduce