In my ArcGIS Python toolbox, I want to be able to create a layer from the selected input feature used to run the tool. I have tried different way although nothing has worked yet. I guess I would need to get the selected feature from here:
....and then create a layer from that in the execute.
Intent is to turn the selected feature into its own layer below.
Solved! Go to Solution.
Thank you. After getting different search engine suggestions, this ended up working out
# Copy selected records into memory
temp_selection = arcpy.management.CopyFeatures(in_features,"temp_selected_layer")[0]
# Add to the map
aprx.activeMap.addLayer(arcpy.management.MakeFeatureLayer(temp_selection, "Parcel of Interest")[0])
You could use the Make Feature Layer tool:
https://pro.arcgis.com/en/pro-app/3.4/tool-reference/data-management/make-feature-layer.htm
The inputs would be your input feature layer.
If you want a persistent layer file, use the Save to Layer File tool:
https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/save-to-layer-file.htm
Thank you. After getting different search engine suggestions, this ended up working out
# Copy selected records into memory
temp_selection = arcpy.management.CopyFeatures(in_features,"temp_selected_layer")[0]
# Add to the map
aprx.activeMap.addLayer(arcpy.management.MakeFeatureLayer(temp_selection, "Parcel of Interest")[0])