Python Addins: Use 'Select Feature' tool with Python Addin?

1392
3
07-31-2012 11:21 AM
MikeMacRae
Occasional Contributor III
I have a script that uses a arcpy's 'SelectByAttribute' syntax to choose a record in a polygon feature class. Following that, I do a 'SelectbyLocation' to select points from a feature class that lie within the selected polygon. I do some processing on the points afterwards.

What I want to know is, can I somehow use the 'Select Features' tool from the 'Tools' toolbar to select the polygon and then use that selection to pass into a python addin button instead of using the 'SelectByAttribute' noted above? I hope this makes sense.

Thanks, Mike
Tags (2)
0 Kudos
3 Replies
MathewCoyle
Frequent Contributor
What I think you are asking is if you can use selections made interactively in arcmap and pass those to the tool. The answer should be yes as long as you reference the layer with the selection in your tool. I haven't jumped in to addins for 10.1 myself yet but you can achieve this functionality with a regular script tool so I assume the same would hold for the new version.
0 Kudos
MikeMacRae
Occasional Contributor III
Thanks Matt. Do you know of any help menu topics that can show how to do it with a regular tool?
0 Kudos
MikeMacRae
Occasional Contributor III
Hey, I discovered that if you set by MapDocument to "CURRENT" in the python add in script, and manually select a polygon, the script honors the selection in the map. I commented out the 'SelectByAttribute' syntax and clicked my new python button and it worked.
0 Kudos