Hi,
How to add table/raster/feature class which are outputted by the tool directly to file geodatabase? Appreciate for any hints 🙂
arcpy.management.MakeFeatureLayer('Min_max_points', 'Min_max_points')
arcpy.AddMessage("Min&Max table added to Contents")
All these datasets are outputted to file gedatabase
but nothing is added to Contents pane
Did you ever find a solution for this? I am having the exact same issue. Running it as a script tool does not add the data to the Contents. However, running my script in ArcPro's Python Window does output data to Contents Pane.
If you're still working on this, I have found that this works for me.
arcpy.MakeFeatureLayer_management("SurveyArea_" + date, "Selection_LayerName")[0]
arcpy.SaveToLayerFile_management("Selection_LayerName", "Selection_LayerName.lyrx")
aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps("Map")[0]
selection = arcpy.mp.LayerFile("Selection_LayerName.lyrx")
m.addLayer(selection, "TOP")[0]
Any luck? Are you running 2.8? I am having the same issues, I've tried all sorts of things, running arcpy.mp but that seems like it mostly used in python window not script tool.
I do have the same problem and the only solution I found is to use a LayerFile to display the dataset, but it is not very fantastic to proceed like this because the .lyrx must exist. But it is a fact that the Content result of the execution of a geoprocessing tool in the Python consol is not the same as if the geoprocessing tool is executed ftom a Python script. Shame on ESRI to not explain this in the documentation.
radius = arcpy.GetParameterAsText(1)
pt = point_geometry.projectAs(spatial_reference_mtm7,"NAD_1983_CSRS_To_WGS_1984_2")
pointGeometryList = []
pointGeometryList.append(pt)
arcpy.CopyFeatures_management(pointGeometryList,r"memory\Point_outil42")
#add a cercle (polygon)
arcpy.analysis.Buffer(r"memory\Point_outil42", r"memory\Outil42", radius, "FULL", "ROUND", "NONE", None, "PLANAR")
#adding the contents of the "memory\Outil42" to the Content using a LayerFile
insertLyr = arcpy.mp.LayerFile("Outil42mem.lyrx")
carte.addLayer(insertLyr)
Also this solution to use a LayerFile creates a problem with exportToPDF() because ArcGIS Pro 2.8.1 freeze after creating the PDF file.
This topic is already over a year old, but I likewise stumbled upon the same issue.
Has there been a more recent solution to this problem? I'm using a python script in combination with a task element, but since outputs aren't added to the map, some steps in the task don't work properly.