I'm creating a suite of add-in tools on a tool bar, and using this tool as a test. How I want it to work is thus:
- I have a buffer which has already been cut up by a line feature class
- I select the portions of the cut-up buffer that I want to keep (will usually be 1-2)
- I then press my add-in button, which switches my selection to all other parts of the buffer (I will then add in 'delete all' functionality).
I have gone through the process and created the add-in project, toolbar, button etc., and loaded it into ArcMap through the customize menu. The button appears as intended, no 'Missing' issues. However, when I attempt to use it as described above, I get an egg-timer for a brief moment, and then nothing appears to happen. There is no change in the selection after I press the button compared to before.
My code:
import arcpy
import pythonaddins
class InverseSelection(object):
"""Implementation for RAFTv2_addin.invbtn (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
buffcut = "U:/ArcGIS/Default.gdb/buffcut"
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
arcpy.SelectLayerByAttribute_management(buffcut, "NEW_SELECTION", "INVERT")
arcpy.RefreshActiveView()
I have also tried "SWITCH-SELECTION", but that didn't work either.
arcpy.SelectLayerByAttribute_management(buffcut, "SWITCH_SELECTION")
.