I haven't found a way of setting the selection method (Create new, Add to current, Remove from current, Select from current selection) in arcpy. Is it possible to do this and - if yes - how?

I am switching between these methods regularly and having to press a modifier key is somewhat error-prone, so I'd like to create a python add-in toolbar that allows me to select the method directly.

Also, I want to select interactively because the features are more or less picked by gut feeling.


arcpy.SelectLayerByAttribute_management and arcpy.SelectLAyerByLocation management both have the optional parameter Selection Type. The value must be one of the following strings:

  • I need to select interactively by gut feeling, so select by attribute or by location are not appropriate here. I have edited the question accordingly. – Christoph Jul 12 '16 at 7:53
  • Have you tried clicking the Selection menu, then Interactive Selection Method, the choosing your desired selection method? – Ali Jul 12 '16 at 7:56
  • Yes of course, and I'd like to shortcut exactly that – Christoph Jul 12 '16 at 7:56
  • In Customize Mode, in Commands Tab of the customize window, under categories, choose Selection. On the right hand side of the window the associated commands will be listed. Here you will find the Add to Current Selection commands etc. which you can drag and drop onto your toolbars for quick access. – Ali Jul 12 '16 at 8:13

While not answering the specific question, I try to aim at the functionality the OP is seeking. I often use these different selection methods myself, and for convenience I have added a dropdown list to my toolbar (and rearranged some of the other buttons):

enter image description here

If this is not enough for you, I'd suggest using the built-in system for creating keyboard shortcuts. You can access it from Customize --> Customize mode --> Keyboard... (This is also the place for adding and rearranging buttons.)

There you can create a custom shortcut for, virtually, any function or button in Arcmap.

enter image description here

  • While this does not answer the exact question, it's very close to what I wanted. Thank you! – Christoph Jul 12 '16 at 9:42
  • 1
    There are actually all four interactive selection methods available to put them into their own toolbar, and arcmap comes with some quite appropriate icons. So I now have my "click once" interactive selection method change – Christoph Jul 13 '16 at 7:06

Yo can do selection by both attribute using arcpy.SelectLayerByAttribute_management and location using arcpy.SelectLayerByLocation_management, but you cannot do selection directly from feature, you should create a temporary layer using arcpy.MakeFeatureLayer_management before doing a selection.

Here is snippet code from the above help:

# Import system modules
import arcpy

# Set the workspace
env.workspace = "c:/data/mexico.gdb"

# Make a layer from the feature class
arcpy.MakeFeatureLayer_management("cities", "lyr") 

# Select all cities which overlap the chihuahua polygon
arcpy.SelectLayerByLocation_management("lyr", "intersect", "chihuahua", 0, "new_selection")

# Within selected features, further select only those cities which have a population > 10,000   
arcpy.SelectLayerByAttribute_management("lyr", "SUBSET_SELECTION", ' "population" > 10000 ')

# Write the selected features to a new featureclass
arcpy.CopyFeatures_management("lyr", "chihuahua_10000plus")

Setting the selection method is an option on the Select Layer By Attributes tool.

However, I am not sure that a Python AddIn will offer the advantage you seek here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.