Select to view content in your preferred language

Use Input Selection to Create a Layer (Python Toolbox)

369
2
Jump to solution
02-02-2026 03:43 PM
BrandonPrice1
Frequent Contributor

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:

BrandonPrice1_0-1770075262645.png

....and then create a layer from that in the execute. 

Intent is to turn the selected feature into its own layer below.

BrandonPrice1_2-1770075536016.png

 

 

 

0 Kudos
1 Solution

Accepted Solutions
BrandonPrice1
Frequent Contributor

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])

 

View solution in original post

0 Kudos
2 Replies
BobBooth1
Esri Regular Contributor

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

BrandonPrice1
Frequent Contributor

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])

 

0 Kudos