Hello,
Any success with this? As of Pro 2.8 I'm having the same issue.
Working from a notebook, this successfully adds a feature class to the map.
import arcpy, os
data = r'path\to\BaseLayer_Processed_Elementary_08302021_clip'
arcpy.env.addOutputsToMap = True
try:
arcpy.management.MakeFeatureLayer(data, data)
except:
print(arcpy.GetMessages())
But, according to the docs the above only creates a temp layer in the map. So, unless you save the map or export the layer to a feature class it won't be saved. So, I tried the below script:
import arcpy, os
data = r'path\to\BaseLayer_Processed_Elementary_08302021_clip'
arcpy.env.addOutputsToMap = True
try:
# Write the selected features to a new featureclass
arcpy.CopyFeatures_management(data, os.path.basename(data))
except:
print(arcpy.GetMessages())
Both scripts work to add a feature class to the map. However, when I convert to a script tool to run within pro it runs successfully, but nothing is added to the map.
Tool version of the script:
import arcpy, os
#input feature class from model. It will be added to the map.
data = arcpy.GetParameterAsText(0)
arcpy.env.addOutputsToMap = True
arcpy.AddMessage(f'adding to map: {data}')
try:
#Copies features from the input feature class or layer to a new feature class.
arcpy.CopyFeatures_management(data, os.path.basename(data))
except:
arcpy.AddMessage(arcpy.GetMessage())
Tool interface: