Numbering floor elements by mark from top to bottom left to right

I am looking for a dynamo script which will be able to give multiple selected floor elements a unique mark reference (with a prefix depending on the type) ordered so that the numbers read top to bottom and left to right. I have managed to create a script which works for piles as they have co-ordinate points in which to locate the elements, however as floors are created with boundaries are causing me some trouble.

Any help is appreciated

Would you be able to graphically represent what you’re going for? My first thought is to get the floor’s geometry using Element.Solids and then calculate its centroid using Solid.Centroid. You can then deconstruct the centroid into its constituent X, Y, and Z components and use a List.SortByKey. For example, if you sort the floors by their centroid’s X component, it will sort them left to right.

Sounds very sensible, I will try that out. (Very new to using Dynamo)
Attached is the kind of thing i am after, darker floors with one prefix and lighter floors with another but adding numbers still left to right

I have managed to identify the centroids of the floors but I cannot seem to sort them to begin renaming them, it might be very simple…

MarkTaggingFloorsByPosition.DYN (6.3 KB)