Select by Location with user input

1345
2
04-09-2013 07:51 AM
TimWitt
Frequent Contributor
Hey everybody,

I have been fighting with this for a while. I was looking to create a button that starts a select by location script with the highlighted parts of select by attribute being configured by the user.

In example: The user clicks on the button and a popup box appears asking the user to select the layers he would like as target features (in_layer). These features are all found in the table of contents.
After selecting the layers another box pops up directing him to select the "select feature" layer (which there is a choice of 5 specific layers). These features are not in the table of content but in a geodatabase.


SelectLayerByLocation_management (in_layer, {overlap_type}, {select_features}, {search_distance}, {selection_type})

Any help is appreciated!
Tags (2)
0 Kudos
2 Replies
TimWitt
Frequent Contributor
For now I only know how to do it if I specify the parameters.


 import arcpy
import pythonaddins

class StormSurge1(object):
    """Implementation for StormSurge_addin.btn1 (Button)"""
    def __init__(self):
        self.enabled = True
        self.checked = False
    def onClick(self):
        arcpy.env.workspace = ('current')
        arcpy.SelectLayerByLocation_management ("Fire Station", "INTERSECT", r"Storm Surge\cat3_full")

0 Kudos
JonPedder
Occasional Contributor II
Try calling a script tool using


pythonaddins.GPToolDialog(PathtoToolbox, 'nameofscriptool')



That way you can prompt for use input
0 Kudos