Select to view content in your preferred language

Adding to a Selection

4000
10
Jump to solution
09-07-2017 10:54 AM
JoeBorgione
MVP Emeritus

Python hack (at best) here....

I would like to base a selection on an already selected record in a layer, and can't quite seem to crack that nut.  Here is the pseudo code:

Select a record  ' in this case a point

Extract the FullStreet attribute value  ' it'll be something like S MAIN ST

Add to the selection all other points that have that same FullStreet field value   'seems like a fairly simple operation

I've been trying to do that using an arcpy.SearchCursor  within the arcpy window :

>>> cursor = arcpy.SearchCursor("apLayer")
>>> for row in cursor:
... street = row.FullStreet
... arcpy.SelectLayerByAttribute_management ("apLayer","ADD_TO_SELECTION","FullStreet = 'street'")
...

>>>

This runs with no errors but only ends up with the originally selected point as being selected.  (See attached)

Questions:  is this a case of newbie syntax error?

                    is there a better approach to do what I intend to do?  

That should just about do it....
0 Kudos
10 Replies
JoeBorgione
MVP Emeritus

Now I get it!

That should just about do it....