I wrote some simple code that created multiple polygons using the Buffer tool. I will use it in a toolbox and therefore want the outFeatureClass to be automatically added to the current map.
The following code doesn't work. "outcome" is the outFeatureClass I want to add.
pw = r"C:\Users\Main\GIS\Data\ArcGISProject\ArcGISProject.gdb\outcome"
aprx = arcpy.mp.ArcGISProject("CURRENT")
aprxMap = aprx.listMaps("Map")[0]
aprxMap.addLayer(pw)
Running the code in the ArcGIS Pro Python command line I receive an error:
"ValueError: r"C:\Users\Main\GIS\Data\ArcGISProject\ArcGISProject.gdb\outcome"
The env.workspace
for the Python file is set to r"C:\Users\Main\GIS\Data\ArcGISProject\ArcGISProject.gdb"
.