I need to create an array of features from a selection based on the order in which they were selected.

As in: I select feature 5,2,3,4. I need to have an array so I can apply attributes (with python) to to these features based on order in which they were selected. This is too apply part numbers to pre-mapped survey plans. To add a part to each is time consuming when their are 50 parts. This would allow me to select them in the order of part number, then apply the correct part with a button I have already created with python.

I've been trying for a long time to figure this out and I have run out of solutions.

I am pretty well versed in Python and with that ArcPy. Seem's like this should be easier then it is.

Thanks for any help.

  • Got any code developed yet? Are you selecting them programmatically? Jun 21, 2012 at 19:19
  • 2
    It sounds like they are being selected interactively, is that correct @Cody?
    – blah238
    Jun 21, 2012 at 19:23
  • Yes, you would select as you would normally with the select by rectangle (or other loop, ext) tool. Then hopefully python or something would keep track of the order
    – Cody Brown
    Jun 22, 2012 at 15:32

1 Answer 1


I do not believe this is possible in the arcpy API.

I thought that maybe the Describe FIDSet property of a feature layer would return the FIDs in the selected order but it does not, it returns the selected feature IDs in ascending order.

This is possible in ArcObjects, according to this answer in my ArcObjects-specific version of this question: Listing features in the order they were selected

However note Ragi's comment that the desired behavior is actually just a side-effect and not guaranteed not to break in newer versions.

If you want to do it right, though, you would have to track this yourself using selection events. You can't do that in arcpy as of 10.0, but it might be possible in ArcGIS 10.1 using Python add-ins (looks like only within an edit session however, see the Extension class documentation).

  • Thanks @blah238 very helpful info. We aren't migrating to 10.1 any time soon though sadly. But, the ArcObjects seems to have a really good plan on doing this. I am already in edit mode for this any ways, so I a going to try er out. Hopefully it will work.
    – Cody Brown
    Jun 22, 2012 at 15:35
  • Unfortunately the linked answer didn't work for me in 10.0 SP4, the IDs were still listed in ascending not selection order.
    – blah238
    Jun 22, 2012 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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