Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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. I'm new to python addins.

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

Whenever you run Python tools from within ArcMap and reference layers from the Table Of Contents as an input to a geoprocessing tool, it honors current selections, and will ignore unselected features. So your script should only select points that intersect currently selected polygons.

Note that this functionality will not work when executing Python scripts from outside of ArcMap.

share|improve this answer
    
Thanks dmahr. I did not realize this. I adjusted my script (removed the 'SelectByAttribute' syntax), installed the addin and opened up a map with a polygon and point feature class. I selected a polygon, ran my button and it worked! –  Mike Jul 31 '12 at 21:15
1  
Glad to hear it Mike! I've clarified the answer a bit so people know that this will not work from outside of ArcMap. –  dmahr Jul 31 '12 at 21:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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