I have an add-in tool created that works perfectly. Yehaw!
It takes your input selection, takes the tools rectangle_geometry, does a load of clever stuff, then clears the selection as work is complete. Its time to make another selection, and use the tool to select your region again.,,,
But I cant find any way to de-activate the tool or set it back to the standard ArcMap select tool after its job is done? Please help!? Its very user unfriendly as if they click again now, it will complain about no selection being present!
I have tried using:
self.deactivate() , but thats not an attribute of my tool :S
Yes that is what I am using. I found this so it doesnt look hopeful:
Its a bit of a pain, I have now to decide whether to code my tool as a "Selector if nothing is selected, or the tool if so", or just leave it as is! Neither is the ideal solution.
@Luke Webb, In your code add an "if" block to see if there is any selection - if yes then put your "takes the tools rectangle_geometry, does a load of clever stuff, then clears the selection as work is complete" code there. In the "else" block you can print a statement or pop-up a message window or do nothing - going ahead to use ArcMap's select tool to make a new selection and use the tool again. Your code may look like:
def onRectangle( .................): dsc = arcpy.Describe("layer_name") selection_set = dsc.FIDSet # returns a list of selected feaures' IDs if selection_set: # that means at least one feature is in selection set # do your stuff ... # .... else: # no feature is selected # pop up a message dialog asking user to select some feature to use the tool pythonaddins.MessageBox("Please select some features to use the tool", 0) # or ... just skip this part pass
Note: the above code is typed in the browsed - there might be syntax error